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); 

相关文章

此处评论已关闭