在进行数据库操作前一定要先初始化数据库类:$this->load->database();
在model类中:
class Myiapp_model extends CI_Model{
public function __construct(){
$this->load->database();
$this->dbName = 'iapp';
}
}
在控制器中:
class Myiapp extends Base_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model("myiapp_model");
$this->pkg = '';
$this->dck = explode(',', file_get_contents('./dck.json'));
}
//列表
public function myiapplist()
{
//导航赋值
$data = $this->getNavList(8, 6);
$data['list'] = $this->myiapp_model->getList(array());
$this->load->view('myiapp/myiapp_list', $data);
}
评论(0)