求助 接连DB一起过不去
错误信息: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
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:
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:
<p><?php echo $temp; ?></p>
<table class="">
<thead>
<tr>
</tr>
</thead>
<tbody>
<?php foreach ($res as $item):?>
<tr>
<td><?php echo $item; ?></td>
</tr>
<?php endforeach;?>
</tbody>
</table>
注:database配置文件,用户名等验证测试正常。未启用自动载入DATABASE。
版本为2.1.3 静候大神出现,我也不知道有什么错 代码看起来没问题。
你的文件名命名和放置路径是不是正确?
页:
[1]