【发布时间】:2010-08-17 16:05:40
【问题描述】:
我有两个 MySQL 表(过于简单):
articles
- id
- description
article_attributes
- article_id
- attribute_name
- attribute_value
因此,每个article 可以拥有无限数量的attributes。
对于articles,我有一个 Kohana_ORM 模型
<?php class Model_Article extends ORM {} ?>
在加载模型时,我希望能够访问所有属性。
例子:
<?php
$article = new Model_Article(1); // or ORM::factory('article', 1);
echo $article->description;
echo $article->attribute->foo;
echo $article->attribute->bar;
?>
有人可以指出正确的方向如何实现这一目标吗?
【问题讨论】: