我在控制器中做了一個查詢,但是讓我注意到我應該在模型中進行查詢。如何在模型中運行查詢並在控制器中加載?
這是我在控制器
$this->db->where('page', 'your-secret-skill');
$this->data['articles'] = $this->article_m->get();
的代碼,這是get方法我在覈心模式:
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();
}
我怎麼會去這樣做查詢在文章模型中加載控制器?
大聲笑,關於閱讀CI文檔 –
的第一線我一直在它是什麼,但沒有爲我工作至今 – tvieira