$query->num_rows nothing returns - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17) +--- Thread: $query->num_rows nothing returns (/showthread.php?tid=62488) |
$query->num_rows nothing returns - mlfgo - 07-20-2015 Within my model I have the following code but does not return anything (running the sql in the bank returns the record). I also tried with $ query-> num_rows also, same thing ... what's wrong? Code: <?php RE: $query->num_rows nothing returns - dimasedu - 07-20-2015 (07-20-2015, 07:05 PM)mlfgo Wrote: Within my model I have the following code but does not return anything (running the sql in the bank returns the record). Maybe you should add value for "FALSE" logic. Like this : if($query->num_rows() > 0){ //code if result not empty }else{ return FALSE; } RE: $query->num_rows nothing returns - Avenirer - 07-20-2015 As I see, your field name in the table is `Usuario`. But when you call it, you do it with 'usuario'. RE: $query->num_rows nothing returns - Wouter60 - 07-20-2015 If it's true that your table name is in lower case and the fields are in firstcaps, then the next question is: do you really want to look for records that literally hold the values 'user' and 'password', or - which is more likely - do you want to get records that match a certain combination of username and password? In that case, your query should look like this: PHP Code: $query = $this->db->query("SELECT * FROM `usuario` WHERE `Usuario` = '$user' AND `Senha` = '$password'"); RE: $query->num_rows nothing returns - mlfgo - 07-22-2015 Thanks friends. Remodeling the question, the instruction Code: $query->num_rows; is some setting? RE: $query->num_rows nothing returns - Narf - 07-22-2015 (07-22-2015, 05:15 AM)mlfgo Wrote: Thanks friends. There's a difference between $this->num_rows and $this->num_rows() ... you should use the latter. |