0
我在學習如何顯示來自兩個表的信息。Kohana ORM顯示信息
表:
categories {category_id, category_title}
forums {forum_id, forum_title}
categories_forums {id_category, id_forum}
型號:
class Model_Forum extends ORM {
protected $_primary_key = 'forum_id';
protected $_belongs_to = array(
'categories'=> array(
'model' => 'category',
'through' => 'categories_forums',
'far_key' => 'id_category',
'foreign_key' => 'id_forum'
),
);
}
class Model_Category extends ORM {
protected $_primary_key = 'category_id';
protected $_has_many = array(
'forums'=> array(
'model' => 'forum',
'through' => 'categories_forums',
'far_key' => 'id_forum',
'foreign_key' => 'id_category'
),
);
}
我不確定如何顯示。
到目前爲止,我有以下幾點:
$categories = ORM::factory('category');
$forums = $categories->forums->find_all();
我怎麼不顯示CATEGORY_ID,category_title,forum_id,FORUM_TITLE。