CodeIgniter PDO -调用未定义方法CI_DB_pdo_mysql_driver::num_rows()


CodeIgniter PDO - Call to undefined method CI_DB_pdo_mysql_driver::num_rows()

我正在尝试编码一个web登录/注册系统,我得到以下错误:

Fatal error: Call to undefined method CI_DB_pdo_mysql_driver::num_rows() in (path to model) on line 7

我也尝试使用rowCount()代替,它仍然不起作用。

这就是模型:

<?php
class Member_model extends CI_Model {
    public function can_log_in() {
        $query = $this->db->select('password')->where('email', $this->input->post('email'));
        if ($query->num_rows() == 1) {
            if (password_verify($this->input->post('password'), $query->row(1))) {
                return TRUE;
            }
        } else {
            return FALSE;
        }
    }
}

此模型链接到登录控制器,该登录控制器使用can_log_in函数通过验证规则(callback_validate_credentials)验证凭据,如果为false则返回验证set_message()。

查询中忘记了table name

$this->db->select('password');
$this->db->where('email', $this->input->post('email'));
$this->db->get('mytable');// add table name in your query