Welcome Guest, Not a member yet? Register   Sign In
Active record Update issue
#1

[eluser]chinedubond[/eluser]
please i keep getting an error with my code below.
i am trying to update a table.
i believe i am doing everything ok.

please help.

Code:
$array = array('timeregistered' => $timereg, 'password' => $password);
        $this->db->set('active', 1);
        $this->db->where($array);
        $query=$this->db->update('ng_contactperson');  

[b]LINE 34[/b]    if($query->num_rows() > 0){
        
        return true;
        
        }
        else{
        
        return FALSE;
        }

Code:
Fatal error: Call to a member function num_rows() on a non-object in D:\dumps\opensource\projects\nightengale\bizlocator\system\application\models\users\usersmodel.php on line 34
#2

[eluser]mironcho[/eluser]
Hi chinedubond, update method doesn't return query object. You can use affected_rows() method instead:
Code:
if ($this->db->affected_rows() > 0)
{
    return true;
}
else
{
    return false;
}
#3

[eluser]m4rw3r[/eluser]
db::update() returns true/false depending on if the query succeeds or not.

Use db->affected_rows() to find how many rows that were altered.

EDIT: to slow Smile




Theme © iAndrew 2016 - Forum software by © MyBB