Welcome Guest, Not a member yet? Register   Sign In
Image upload problem
#6

[eluser]TheFuzzy0ne[/eluser]
Sure.

Code:
// Set a default to prevent an error being thrown if no ID is passed.
function select_user_by_id($id = 0)
{
    // Always use single quotes if you don't need to parse variables within
    // the string. It gives a performance boost.
    $q = $this->db->query(
        'SELECT * FROM users WHERE id = ?',
        array($id),
    );

    // Ta-daaa! Now the query returns a single object, instead of an array
    // of the little buggers...
    return ($q->num_rows() == 1) ? $q->row() : false;
}

Hope this helps.


Messages In This Thread
Image upload problem - by El Forum - 03-21-2013, 09:27 PM
Image upload problem - by El Forum - 03-22-2013, 05:48 AM
Image upload problem - by El Forum - 03-22-2013, 06:31 AM
Image upload problem - by El Forum - 03-22-2013, 07:14 AM
Image upload problem - by El Forum - 03-22-2013, 12:37 PM
Image upload problem - by El Forum - 03-22-2013, 01:13 PM
Image upload problem - by El Forum - 03-22-2013, 03:42 PM
Image upload problem - by El Forum - 03-23-2013, 01:38 AM
Image upload problem - by El Forum - 03-23-2013, 03:00 AM
Image upload problem - by El Forum - 03-23-2013, 03:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB