Welcome Guest, Not a member yet? Register   Sign In
$query->num_rows nothing returns
#2

(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).
 
I also tried with $ query-> num_rows also, same thing ... what's wrong?


Code:
<?php
class login_model extends CI_Model{

function ValidaLogin()
{

$query = $this->db->query("SELECT * FROM `usuario` WHERE `Usuario` = 'user' AND `Senha` = 'password'");

if ($query->num_rows() > 0)
{
  foreach ($query->result() as $row)
  {
     echo $row->usuario;
  }
}

Maybe you should add value for "FALSE" logic. Like this :
if($query->num_rows() > 0){
 //code if result not empty
}else{
  return FALSE;
}
Reply


Messages In This Thread
$query->num_rows nothing returns - by mlfgo - 07-20-2015, 07:05 PM
RE: $query->num_rows nothing returns - by dimasedu - 07-20-2015, 10:05 PM
RE: $query->num_rows nothing returns - by mlfgo - 07-22-2015, 05:15 AM
RE: $query->num_rows nothing returns - by Narf - 07-22-2015, 06:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB