|
错误信息:
Fatal error: Call to a member function database() on a non-object in D:\xampp\htdocs\test_php100.com\ci_offer\app_offer\models\GoodsInfo_M.php on line 8
源码:
model:
PHP复制代码 <?php
class GoodsInfo_M extends CI_Model{
public function __construct(){
parent ::__construct();
$this->load->database();
}
public function GetMyResult(){
$sql = "select * from goods_info";
$query = $this->db->query($sql);
$result = $query->result();
return $result;
}
} 复制代码
controller:
PHP复制代码 class GoodsInfo_C extends CI_Controller {
public function __construct(){
parent::__construct();
}
public function index(){
$this->load->model('GoodsInfo_M','GoodsInfo_M',true);
$result = $this->GoodsInfo_M->GetMyResult();
if($result){
$data['temp'] = "kdkd";
}
$this->load->view('ShowInfo', $data);
} 复制代码
VIEW:
注:database配置文件,用户名等验证测试正常。未启用自动载入DATABASE。
|
|