【发布时间】:2015-03-07 15:21:18
【问题描述】:
示例: 对于数据库中的表,我有以下两个类。
class Post extends Model {}
class User extends Model {
public function posts() {
return $this->has_many('Post'); // Note we use the model name literally - not a pluralised version
}
}
现在我想在一个变量中查询所有用户及其相关帖子。 类似的东西:
$user = Model::factory('User')->find_many();
// Find the posts associated with the user
$posts = $user->posts()->find_many();
我想在 $posts 变量中得到结果。
【问题讨论】:
-
你有什么错误吗?你的输出是什么?
-
是的,它给出了错误 post() 函数
-
什么样的错误?请使用您的错误的全部内容编辑您的问题。谢谢。