我正在研究这个问题,使用CRUD教程:
public function get($id = NULL, $single = FALSE){
if ($id != NULL) {
$filter = $this->_primary_filter;
$id = $filter($id);
$this->db->where($this->_primary_key, $id);
$method = 'row';
}
elseif($single == TRUE) {
$method = 'row';
}
else {
$method = 'result';
}
if (!count($this->db->ar_orderby)) {
$this->db->order_by($this->_order_by);
}
return $this->db->get($this->_table_name)->$method();
}
但我收到此错误消息:
A Database Error Occurred
Error Number: 1046
No database selected
SELECT * FROM (`pages`) WHERE `slug` = 'about' ORDER BY `order`
Filename: /var/application/core/MY_Model.php
Line Number: 34($this->db->get($this->_table_name)->$method();)
如何选择数据库?
答案 0 :(得分:0)
您需要在/application/config/database.php
此外,如果您使用的是环境,则可能需要编辑/application/config/{ENVIRONMENT}/database.php
文件。