我即将实施解析器类到我的codeigniter项目,并希望将数据从模型传递到解析器数组。哪种做法更好,效率更高。Codeigniter将数据从模型传递到控制器分析程序
我的模型获取数据并将其返回给控制器。我怎样才能把它放入控制器的数组中?
型号:
function getSeo($data){
$this->db->select('seo_title, seo_description, seo_keywords');
$this->db->from('content');
$this->db->where($data);
$query = $this->db->get();
$data = array();
foreach ($query->result() as $row) {
$data[] = array(
'seo_title' => $row->seo_title,
'seo_description' => $row->seo_description,
'seo_keywords' => $row->seo_keywords
);
}
return $data;
}
控制器:
$viewdata['pageseo'] = $this->Content_model->getSeo($data);
$viewdata = array(
'seo_title' => 'My seo Title',
'seo_description' => 'My seo description',
'seo_keywords' => 'My seo keywords',
);
什么是从我的模型中的数据为 '$可视数据' 数组的最佳方式,它怎么办????