數據庫查詢方式:
~~~
1.application/config/database.php
$active_record = TRUE;
2.在配置文件中,配置表前綴后,會自動添加
$res=$this->db->get('表名');//返回結果集對象
$res->result();
~~~
在application/config/autoload.php上設置database自動連接:
`$autoload['libraries'] = array('database');`
___
~~~
//查詢整個數據表
function show($data = 'message'){
$query = $this->db->get($table);
return $query;
}
~~~
在模擬代碼的過程中,為減少涉及的文件引起的不確定性,可以在單個文件內引起database:
```
public function __construct()
{
parent::__construct();
$this->load->database();
$this->load->model('Target_model');
}
```