Welcome Guest, Not a member yet? Register   Sign In
Not getting the result I'm expecting from this simple query
#1

[eluser]dallen33[/eluser]
Code:
$query = $this->db->get_where('clients', array('name' => $name))->row()->id;
        
        if ($query->num_rows() > 0):
            return $query->result();
        else:
            return false;
        endif;

Any idea what I'm doing wrong? I'm expecting to get the actual ID from "return $query->result();". What might I be doing wrong?
#2

[eluser]pickupman[/eluser]
Once you call the the query ->row() method, $query is not a result object. That means $query->num_rows() will be false. Use this instead.
Code:
$query = $this->db->get_where('clients', array('name' => $name))->row();
        
if ( count($query) > 0)
   return $query->id;
        
return FALSE;
The else is not needed as there is only one other option to return which is FALSE.




Theme © iAndrew 2016 - Forum software by © MyBB