$where['class_id'] = ['in', '$cid_all'];
$where['id'] = ['in', $all_user_id];//或这样子
$where['title'] = ['like', '%php%'];
$where['id'] = ['<>', $id];
$where['id'] = ['notin', $all_user_id];//不等于
与find_in_set()相反的函数可以用!find_in_set()
//值为数字
$id=419;
$where[] = ['exp',Db::raw("FIND_IN_SET($id,category)")];//category值为数字,例子:419,415,414
//值为字符串
$id值等于dfd 要注意'引号
$where[] = ['exp',Db::raw("FIND_IN_SET('$id',category)")];//category值为数字,例子:'349/417/419','349/413/415','349/413/416'
Db::name('menu')->where('FIND_IN_SET(:id,pid_all)',['id' => $id])->update([$field => $title]);

type 字段在数据库是以 1,2,3 形式存在 已说到FIND_IN_SET函数的使用

对于一些实在复杂的查询,比如find_in_set,也可以直接使用原生SQL语句进行查询,例如:

Db::table('think_user')
->where('find_in_set(1,sids)')
->select();::table('think_user')
->where('find_in_set(1,sids)')
->select();

为了安全起见,我们可以对字符串查询条件使用参数绑定,例如:

Db::table('think_user')
->where('find_in_set(:id,sids)',['id'=>$id])
->select();::table('think_user')
->where('find_in_set(:id,sids)',['id'=>$id])
->select();

自己的实例:

$gonggaolist = Db::table("fa_cms_archives")
->alias('a')
->join("fa_cms_channel w","a.channel_id=w.id")
->where("w.parent_id=20 and a.status='normal'")
->where("FIND_IN_SET('recommend',a.flag)")
->order("a.id desc")
->field("a.id,a.channel_id,a.title,a.likes,a.image,w.diyname,a.updatetime,a.flag")
->limit("4")
->select();
dump($gonggaolist);

效果图

最新文章

  1. MyEclipse for Spring启动时报错&quot;An internal error occurred during: &#39;Updating indexes&#39;.Java heap space&quot;的解决办法
  2. Libfilth(一个滤波器C库)使用
  3. password安全之动态盐
  4. UrlPathEncode与UrlEncode的区别
  5. MariaDB设置主从复制[转载]
  6. Radar Installation(贪心,可以转化为今年暑假不ac类型)
  7. Kendo UI开发教程(25): 单页面应用(三) View
  8. QuickSwitchSVNClient,快速完成SVN Switch的工具
  9. ubuntu12.04 安装中文输入法
  10. C#并发编程实例讲解-概述(01)
  11. NtDuplicateObject小解读
  12. HTTP 0.9 HTTP 1.0 HTTP 1.1 HTTP 2.0区别
  13. Redis基础知识补充及持久化、备份介绍(二)--技术流ken
  14. sessionStorage实现note的功能
  15. Centos7安装JDK8以及环境配置
  16. sql 计算两个经纬度点之间的距离
  17. C# 获取Image图片格式
  18. angularjs 之 $watch
  19. 记一次有趣的 Netty 源码问题
  20. JavaEE互联网轻量级框架整合开发(书籍)阅读笔记(8):装配SpringBean概述(如何合理使用装配级别)

热门文章

  1. RF之简介
  2. 12-19 js
  3. Key Management: Hardcoded Encryption key 密钥管理:硬编码加密密钥
  4. AndroidStudio3.0升级成3.5后之前项目报错解决
  5. ORA-27090: Unable to reserve kernel resources for asynchronous disk I/O
  6. 关于字符串的格式化----format与%
  7. Security+学习笔记
  8. mysql5.7中timestam默认值&#39;0000-00-00 00:00:00&#39;报错
  9. Java之StringBuilder类
  10. Shape.Type属性名称及对应值列表