请原谅我发布的未code
格式化的代码。有时无法让四个空间工作。
你好。寻找有关 CodeIgniter 中 num_rows() 函数引起的此错误的一些见解。
Fatal error: Call to undefined method CI_DB_mysql_driver::num_rows() in [my controller]
它似乎以某种方式植根于此……可能:
A PHP Error was encountered
Severity: 4096
Message: Object of class CI_DB_mysql_driver could not be converted to string
Filename: database/DB_active_rec.php
Line Number: 427
第 427 行显示: $v = ' '.$this->escape($v);
并且来自函数:protected function _where($key, $value = NULL, $type = 'AND ', $escape = NULL)
我正在使用 CodeIgniter 和 IonAuth,当我调用此函数时,问题似乎来自 num_rows(): public function login($identity, $password, $remember=FALSE) { $this->trigger_events('pre_login') ;
if (empty($identity) || empty($password))
{
$this->set_error('login_unsuccessful');
return FALSE;
}
$this->trigger_events('extra_where');
$query = $this->db->select($this->identity_column . ', username, email, id, password, active, last_login')
->where($this->identity_column, $this->db->escape_str($identity))
->limit(1);
echo $query;
if ($query->num_rows() === 1)
{
$user = $query->row();
$password = $this->hash_password_db($user->id, $password);
if ($password === TRUE)
{
if ($user->active == 0)
{
$this->trigger_events('post_login_unsuccessful');
$this->set_error('login_unsuccessful_not_active');
return FALSE;
}
$session_data = array(
'identity' => $user->{$this->identity_column},
'username' => $user->username,
'email' => $user->email,
'user_id' => $user->id, //everyone likes to overwrite id so we'll use user_id
'old_last_login' => $user->last_login
);
$this->update_last_login($user->id);
$this->clear_login_attempts($identity);
$this->session->set_userdata($session_data);
if ($remember && $this->config->item('remember_users', 'ion_auth'))
{
$this->remember_user($user->id);
}
$this->trigger_events(array('post_login', 'post_login_successful'));
$this->set_message('login_successful');
return TRUE;
}
}
//Hash something anyway, just to take up time
$this->hash_password($password);
$this->increase_login_attempts($identity);
$this->trigger_events('post_login_unsuccessful');
$this->set_error('login_unsuccessful');
return FALSE;
}
我想知道他们在那里使用的查询是否有问题。CI_DB_mysql_driver 上的任何线索都会有所帮助......
提前致谢!