thinkphp5 tp5 子查询 join
$GLOBALS["queryid"] = $id;
$res = Db::name("cfamily_post")->where("delete_time", 0)->where('id', 'in', function ($query)
{
$query->name("cfamily_category_post")->where('category_id', $GLOBALS["queryid"])->field('post_id');
})
->page($page, $listRows)->select();
$join = [
["cfamily_category_post relation","post.id = relation.post_id"],
];
$where = [
"post.delete_time" => "0",
"relation.category_id" => $id,
];
$res = Db::name("cfamily_post")->alias('post')->field("post.*")->join($join)->where($where)->page($page,$listRows)->select();
dump($res);
最后更新于 2017-08-28 02:24:45 并被添加「join thinkphp5 tp5 子查询」标签,已有 706 位童鞋阅读过。
此处评论已关闭