我正在寻找针对我的问题的帮助,因为我似乎无法从 Kohana 文档或谷歌搜索中得到它。
我有 2 张桌子:
contents
id
uri
标题
template_id
templates
身份证
标题
我正在尝试返回contents
具有匹配uri的行的所有数据。
目前我有两个模型:内容和模板。
内容
class Model_Content extends ORM {
protected $_table_name = 'contents';
protected $_has_one = array('template' => array());
....
模板
class Model_Template extends ORM {
protected $_table_name = 'templates';
protected $_belongs_to = array(
'content' => array()
);
然后在我的控制器中:
$item = ORM::factory("Content")->get_by_uri($uri);
这指向:
$this->where("uri", "=", $uri)->find();
这会正确返回内容表中的数据,但是如何从模板表中引入模板名称?
感谢您对此的帮助。