• Thinkphp的 is null 查询条件是什么,以及exp表达式如何使用


    Thinkphp的 is null 查询条件是什么,以及exp表达式如何使用

    一、总结

    一句话总结:$map['name'] = array('exp','is null');

    1、is null判断的常见错误写法有哪些?

    1、

    $map1['f_jieduan_id']=['=',null];
    $map1['f_g_id']=['=',null];

    2、

    $map1['f_jieduan_id']=['is null'];
    $map1['f_g_id']=['is null'];

    3、

    $map['name'] = array('is',null);//无法实现

    2、thinkphp中exp表达式如何使用,作用是什么?

    其实就是告诉thinkphp这是原生的sql语句

    关于exp表达式:
    可支持任何sql语法
    如:

    $map['id'] = array('between',array(1,5));

    可写成:

    $map['id'] = array('exp','between (1,5)');

    还可用于数据更新:

    $data['age'] = array('exp','age+1');
    M('user')->where('id=1')->save($data);//该用户的年龄加1

    二、Thinkphp的 is null 查询条件,以及exp表达式的使用

    Thinkphp中若要用到 is null 查询条件,使用以下方法无法实现:

    $map['name'] = array('is',null);//无法实现

    可使用exp表达式:

    $map['name'] = array('exp','is null');

    关于exp表达式:
    可支持任何sql语法
    如:

    $map['id'] = array('between',array(1,5));

    可写成:

    $map['id'] = array('exp','between (1,5)');

    还可用于数据更新:

    $data['age'] = array('exp','age+1');
    M('user')->where('id=1')->save($data);//该用户的年龄加1
     
     
    参考:Thinkphp的 is null 查询条件,以及exp表达式的使用 - CSDN博客
    https://blog.csdn.net/codercwm/article/details/51523963
     

    三、is null判断的常见错误写法

    1、

    $map1['f_jieduan_id']=['=',null];
    $map1['f_g_id']=['=',null];

    2、

    $map1['f_jieduan_id']=['is null'];
    $map1['f_g_id']=['is null'];

    3、

    $map['name'] = array('is',null);//无法实现
     
  • 相关阅读:
    【Linux 编程】进程间通信
    毕设进行时——4.3寸在富士通ARM中实现
    spcomm使用:在编译运行时为什么总出现"unable to open include file 'spcomm.hpp'"?
    Xilinx LVDS
    Xilinx selectIO
    xilinx 原理图输入
    http消息头(转)
    用java语言将数据库中的数据表转换为xml文件的通用程序(转)
    数据字典实例
    Web Service工作原理初探
  • 原文地址:https://www.cnblogs.com/Renyi-Fan/p/9558639.html
Copyright © 2020-2023  润新知