我正在尝试学习如何显示两个表格中的信息。
表:
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。