0
好了,我已经在我的模型如下功能:使用变量
public function get_learning_category_list() {
$categorias = $this->db->select('t1.id, t1.title, t1.metadata, t1.meta_title, t1.description, t1.meta_description, t1.meta_spam, t1.url, t1.alt_img')
->from('learning_category t1')
->join('learning_rel_category t4', 't1.id = t4.category_id', 'left')
->join('learning t2', 't4.learning_id = t2.id', 'left')
->join('learning_rel_language t3', 't2.id = t3.learning_id', 'left')
->where('t3.language', $this->language)
->group_by('t1.id')
->get()->result_array();
foreach($categorias as $c){
$total = $this->db->select('count(learning_rel_language.learning_id) as total', false)
->from('learning')
->join('learning_rel_language', 'learning.id = learning_rel_language.learning_id', 'inner')
->join('learning_rel_category', 'learning.id = learning_rel_category.learning_id', 'inner')
->where('learning_rel_category.category_id', $c['id'])
->where('learning_rel_language.language', $this->language)
->group_by('learning_rel_language.language')->get()->first_row('array');
$metadata = json_decode($c['metadata']);
$tt = $c['title'];
$url = $c['url'];
if($this->language != 'pt_br'){
$tt = $metadata->{$this->language};
$tt_pt_br = $c['title'];
}
$return[] = array('url' => $url, 'title'=>$tt, 'id'=>$c['id'], 'total'=>$total['total'], 'title_pt_br'=>$tt_pt_br);
}
return $return; //$categorias;
}
给在该值的print_r($this->learn->get_learning_category_list());
我的结果:
Array ([0] => Array ([url] => [title] => Title [id] => 2 [total] => 6 [title_pt_br] =>)
美容?但我需要使用(相同的模型)这些值,网址和标题等。我该怎么做?
作为更具体的,我要在这里使用:
$category_format = (here title).'-cmdo-'.(here id);
。
它的工作!但是结果出现在Array中,我怎样才能使它成为一个对象? – GWER
看到我的编辑,不要忘记将答案设置为正确:) –
是的,谢谢兄弟! – GWER