EllisLab text mark
Advanced Search
     
PHP Fatal error:  Call to undefined method CI_DB_mysql_driver::num_rows() ?
Posted: 05 November 2012 01:25 PM
Avatar
Joined: 2010-11-24
94 posts

Error Message:

PHP Fatal error:  Call to undefined method CI_DB_mysql_driver::num_rows() in /home/site/public_html/jazauth/application/core/MY_Model.php on line 265 


MY_Model:

public function login($username$password)
    
{
     
//check for emptiness.
     
if(empty($username) || empty($password)) {
      
return FALSE;
     
}
  
     
//Check if username and password exist in users table.
     //select record where username = $username
  
$q $this->db->select('id, group_id, username, password, email')
     ->
from('users')
     ->
where('username'$username)
     ->
where('password'sha1($password))
     ->
limit(1)
     ->
get();

  if (
$q->num_rows() > 0)
  
{
     
foreach ($q->result() as $row)
     
{
    
//Store data into session
    
$session_data = array(
     
'id'                   => $row->id//kept for backwards compatibility
     
'user_id'              => $row->id//everyone likes to overwrite id so we'll use user_id
     
'group_id'             => $row->group_id,
     
'username'             => $row->username,
     
'email'                => $row->email
      
);

    
$this->session->set_userdata($session_data);
   
         echo 
'username: '$row->username;
         echo 
'<br>password: '$row->password;
     
    
      return 
TRUE;
     
}
  }
  
else 
  
{
   
echo '<pre>';
   
print_r($q);
   echo 
'</pre>';
   return 
FALSE
  
}
 } 

The Line 265 above is,

->get(); 


Thanks in advanced.

 Signature 

Don’t click this link.

 
Posted: 05 November 2012 01:49 PM   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2010-11-24
94 posts

I think I have another error.

 Signature 

Don’t click this link.

 
Posted: 05 November 2012 04:58 PM   [ # 2 ]   [ Rating: 0 ]
Joined: 2009-04-15
475 posts

http://ellislab.com/forums/viewthread/156420/#945618

 Signature 

Code By Jeff

Mahana Messaging Library

Problem with your query? Did you run

$this->db->last_query(); 

before you came to the forums for help?