zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    Java——快速排序
    Java——归并排序
    Java——递归
    Java——希尔排序
    Java——插入排序
    Java——选择排序
    ES6快速入门
    ECharts is not Loaded
    scoped的规则
    css哪些样式属性可以继承
  • 原文地址:https://www.cnblogs.com/clubs/p/9304505.html
Copyright © 2011-2022 走看看