大佬教程收集整理的这篇文章主要介绍了需要帮助的巴黎PHP查询,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
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变量中得到结果.
解决方法:
我已经解决了这个问题
$user = Model::factory('User')->find_many();
// Find the posts associated with the user
//$posts = $user->posts()->find_many();
我遍历$user并将每个用户ID传递给$user-> posts()-> find_one();
foreach($user as $usr)
{
$posts = $user->posts()->find_one($usr->Id);
}
以上是大佬教程为你收集整理的需要帮助的巴黎PHP查询全部内容,希望文章能够帮你解决需要帮助的巴黎PHP查询所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。