【问题标题】:Call to a member function num_rows() on boolean [closed]在布尔值上调用成员函数 num_rows() [关闭]
【发布时间】:2015-08-22 11:34:58
【问题描述】:

在 C:\xampp\htdocs\c\application\models\usermodel.php 第 138 行的布尔值上调用成员函数 num_rows()

public function new_pass(){

    $email = $this->input->post('email');
    $pass1 = $this->input->post('pass1');
    $pass2 = $this->input->post('pass2');

    $result = $this->db->where('email', $email)->update('user',[
        'pass1' => $pass1,
        'pass2' => $pass2,
    ]);

    if ($result->num_rows() == 1) {
        return TRUE;
    }else{
        return FALSE;
    }
}

【问题讨论】:

标签: php codeigniter mysqli


【解决方案1】:

对于插入和更新查询,我们使用$this->db->affected_rows()

也改变你的查询

public function new_pass(){

    $email = $this->input->post('email');
    $pass1 = $this->input->post('pass1');
    $pass2 = $this->input->post('pass2');
    $this->db->set('pass1',$pass1);
    $this->db->set('pass2',$pass2);
    $result = $this->db->where('email', $email);
    $this->db->update('user');

    $afftectedRows = $this->db->affected_rows();
     if ($afftectedRows == 1) {
        return TRUE;
    }else{
        return FALSE;
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-29
    • 2017-09-25
    • 1970-01-01
    • 2021-05-23
    • 2018-12-17
    • 2018-10-20
    • 1970-01-01
    相关资源
    最近更新 更多