当前位置:网站首页>TP5的whereOr方法多条件存在
TP5的whereOr方法多条件存在
2022-07-15 16:49:00 【自己收藏学习】
$where['a'] = '1';
$where['b'] = '2';
$where['c'] = '3';
$whereOr['a'] = '1';
$whereOr['b'] = '2';
$whereOr['c'] = '3';
$data = Db::name('matorder')->where($where)->whereOr($whereOr)->select();
这样查出来的结果不是我想要的,SQL语句为
SELECT * FROM `table` WHERE `a` = '1' AND `b` = '2' AND `c` = '3' OR `a` = '1' OR `b` = '2' OR `c` = '3';
我想要的是这样的一个查询语句:
SELECT * FROM `table` WHERE ( `a` = '1' AND `b` = '2' AND `c` = '3' ) OR ( `a` = 1 AND `b` = '2' AND `c` = '3' );
后来看手册,发现可以通过混合查询达到效果,下面是手册图:

因为自己之前用的闭包不多,所以不怎么了解闭包传参,还好后面查到了
$data = Db::name('table')->where(function ($query) use ($where) {
$query->where($where);
})->whereOr(function ($query) use ($whereO) {
$query->where($whereO);
})->select();
这就是想要的结果了,此文仅为记录防止忘记
边栏推荐
- TCP 三次握手、四次挥手图解
- [problems of dft/fft - solutions to fence effect]
- Design and implementation of fingertip Roulette Games (uniapp implements wechat applet)
- 8. MySQL -- trigger
- markdown学习笔记 第二章 基本语法 (markdown编辑器下显示)
- Private cloud ranking of Tangmen concealed weapons
- Preliminary introduction of CAN protocol
- Unet++ 网络tensorflow版(slim实现)
- 初学者怎么快速学会SQL
- Deep learning loss function
猜你喜欢

Implementation of sequence table in C language stack

oracle怎样转义单引号

C language Chapter 8 array

Excel import / export annotation General Edition

Live broadcast artifact Lavalier wireless microphone-ldr6028 power charging OTG scheme

基于TaskScheduler和CronTask实现动态增删启停定时任务功能

TimeSformer: 只靠 Transformer 就能理解视频?注意力机制的又一次进击

Type-c边充边传数据应用OTG功能(LDR6028S)

Design and implementation of fingertip Roulette Games (uniapp implements wechat applet)

Thumbnailator 图片处理类库
随机推荐
Is there a limit on the length of string? How much is it?
8. MySQL -- trigger
scala 分支控制 (单分支、双分支、多分支)、 分支判断的返回值
[cloud native] 3.4 ruoyi cloud deployment practice (Part 1)
H264-解码顺序 显示顺序 参考顺序
flex&bison 高级计算器
Thumbnailator 图片处理类库
About some string related functions, memory functions and some simulations
Type-C application OTG function while charging and transferring data (ldr6028s)
Domestic light! High score spatiotemporal representation learning model uniformer
urllib.error.URLError: <urlopen error [Errno 11004] getaddrinfo failed>
Design and implementation of fingertip Roulette Games (uniapp implements wechat applet)
ICCV 2021 的最佳论文模型 Swin Transformer 终于对视频下手了
IDEA类文档注释模板设置
Type-C charging OTG chip (ldr6028s)
2021年全国职业院校技能大赛(中职组)网络安全竞赛试题(9)思路
Redis-安装&&启动
1-初识FPGA
C语言 第八章 数组
centernet(objects as points)的尝试[基于tf.slim]