我工作的這一點,使用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();)
如何選擇數據庫?
似乎沒有找到數據庫「網頁」。檢查在application/config/database上是否正確定義了正確的名稱和配置設置。 – 2013-05-05 23:50:22
@Lior其實'頁面'是表格... – Hailwood 2013-05-05 23:54:59
是頁面是表格名稱我怎樣才能{SELECT * FROM('pages')where'slug' ='about'ORDER BY'order'}這些查詢起作用,謝謝 – mercy 2013-05-06 00:06:10