tp5閉包子查詢傳參方法


在channel表中查詢status,channel_id,channel_name,account_level這些字段,且這些字段的channel_id不在adv_id為$id的表adv_channel_rule中:

$model = new Model();
$id = $req_models["id"];

tp5閉包子查詢傳參:

$res = $model->table('channel')
    ->field(['status','channel_id','channel_name','account_level'])
    ->where('channel_id','NOT IN',function($query) use ($id) {
    $query->table('adv_channel_rule')->where("adv_id",$id)->field('channel_id');
    })->select();

mysql的原生寫法:

$res = 'SELECT adv_id,adv_name,status,account_level FROM `channel` WHERE channel_id NOT IN (SELECT channel_id FROM adv_channel_rule WHERE adv_id='.$id.')';
$result = $model->query($res);

文章轉載:https://blog.csdn.net/weixin_36185028/article/details/79499872


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM