A PHP Error was encountered
A PHP Error was encounteredSeverity: NoticeMessage: Undefined property: newfile::$nani_model
Filename: controllers/newfile.php
Line Number: 7
Fatal error: Call to a member function set() on a non-object in C:\xampp\htdocs\CI2\application\controllers\newfile.php on line 7
求助。。。这该怎么哦?
问题补充。。。
。。。。。。。->
控制器中的代码:
<?php
class newfile extends CI_Controller{
public function action()
{
$name = $this->input->post('name');
$pass = $this->input->post('pass');
$query = $this->nani_model->set($name,$pass);
if($query == 0)
{
$this->load->view('news_pages/denglu');
}
else $this->load->view('news_pages/text1');
}
public function xianshi()
{
$this->load->helper('url');
$this->load->view('news_pages/denglu');
}
}
模型中的代码:
<?php
class nani_model extends CI_Model
{
function __construct()
{
parent::__construct();
$this->load->database();
}
public function set($name,$pass)
{
$sql = "select * from admin where name = '$name' and pass = '$pass' ";
$query = $this->db->query($sql);
return $query->num_rows();
}
}
你的控制器都没有加载对应的模型。。 要先 $this->load->model('nani_model');
然后才能 $this->nani_model->XXX(); 同意楼上看法 Ding 发表于 2012-6-7 14:34 static/image/common/back.gif
要先 $this->load->model('nani_model');
然后才能 $this->nani_model->XXX();
恩,谢了!
页:
[1]