gpt4 book ai didi

php - fatal error : Call to a member function where() on a non-object codeigniter $query->num_rows()==1)

转载 作者:可可西里 更新时间:2023-11-01 07:37:38 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
CodeIgniter - Call to a member function select() on a non-object

我是 codeigniter 的新手,遇到了一些问题。

错误消息: fatal error :在 C:\xampp\htdocs\moi\CI\application\models\model_users 中的非对象上调用成员函数 where()。第 12 行的 php

我的模型:

class Model_users extends CI_Model {

function __construct(){
parent::__construct();
}

public function can_log_in() {


$this->db->where('email', $this->input->post('email'));
$this->db->where('pass', md5($this->input->post('password')));
$query = $this->db->get('users');

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

我的 Controller :

class Main extends CI_Controller {

public function index() {
$this->login();
}

//Auslagern der Funktionen
public function login() {
$this->load->view('login');
}

public function login_validation() {

$this->load->library('form_validation');

$this->form_validation->set_rules('email', 'email', 'required|valid_email|xss_clean|callback_username_check');
$this->form_validation->set_rules('password', 'password', 'required|md5');

if ($this->form_validation->run()) {
redirect('main/members');
} else {
$this->load->view('login');
}
}

public function username_check() {
$this->load->library('form_validation');
$this->load->model('model_users');
if ($this->model_users->can_log_in()) {
return TRUE;
} else {
$this->form_validation->set_message('username_check', 'incorect User or Passwort.');
return FALSE;
}
}

}

求助

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com