Welcome Guest, Not a member yet? Register   Sign In
implementing database functions
#1

[eluser]introvert[/eluser]
Hello,

Can someone post a simple example how to most effectively implement database functions:

For instance, get_item function:

Code:
function get_item($params, $limit = 1, $offset = 0) {
    $query = $this->CI->db->get_where('data', $params, $limit, $offset);
    return $query->result();        
}

Also, how can I return just the zelo element (if limit is set to 1) like return $query->result()[0]; ?

Thanks for help!
#2

[eluser]Dam1an[/eluser]
If you just need one item, you can use row() instead of result() (there's also row_array if you prefer to work with arrays)




Theme © iAndrew 2016 - Forum software by © MyBB