0
我使用CodeIgniter活動記錄,並且缺乏在MySQL中連接多個表列的知識。加入兩個MySQL列並輸出colB.name,其中colA.id等於colB.id
我基本上想要做的,是輸出從ci_categories
表中的所有行,但不是顯示ci_categories.component_id
爲數字,我希望輸出的ci_components.name
通過使用具有相等(或相同)ci_components.id
從另一個表ci_components
CodeIgniter中的活動記錄。
我已經做了,但有錯誤是:
型號:
public function getItemName($id){
$this->db->select('*');
$this->db->where('id', $id);
$result = $query->result();
return $result;
}
和查看:
<?php echo $this->component_model->getItemName($cat['category']->com_id);?>
任何提示請?
而且在那裏我應該把這個代碼,在這種模式?進入'categories_model'或者'component_model'? – aspirinemaga 2013-05-07 15:36:01
我可能會使用組件,因爲我們試圖檢索組件的名稱。 – stormdrain 2013-05-07 15:41:19