当前位置:网站首页>The whereor method of TP5 has many conditions
The whereor method of TP5 has many conditions
2022-07-27 16:22:00 【Collect and learn by yourself】
$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();
The result of this check is not what I want ,SQL Statement for
SELECT * FROM `table` WHERE `a` = '1' AND `b` = '2' AND `c` = '3' OR `a` = '1' OR `b` = '2' OR `c` = '3';
What I want is such a query statement :
SELECT * FROM `table` WHERE ( `a` = '1' AND `b` = '2' AND `c` = '3' ) OR ( `a` = 1 AND `b` = '2' AND `c` = '3' );
Later, I read the manual , It is found that the effect can be achieved through hybrid query , The following is the manual diagram :

Because I didn't use many closures before , So I don't know much about closure parameters , Fortunately, I found it later
$data = Db::name('table')->where(function ($query) use ($where) {
$query->where($where);
})->whereOr(function ($query) use ($whereO) {
$query->where($whereO);
})->select();
This is the desired result , This article is only for record to prevent forgetting
边栏推荐
猜你喜欢

SolidWorks Simulation曲线图属性设定

COMS Technology

DRF use: get request to get data (small example)

DRF learning notes (I): Data Serialization

使用transform:translate()出现内容模糊问题

JSP Foundation

文本截取图片(哪吒之魔童降世壁纸)

webRTC中的coturn服务安装

flume增量采集mysql数据到kafka

C channel simply implements the publishing and subscription of message queue
随机推荐
Leetcode 226 翻转二叉树(递归)
Mapreduce实例(二):求平均值
vant-ui toast和dialog使用
Determine the exact type of data
时间序列-ARIMA模型
Time series ARIMA model
The difference and use between get request and post request
Pychart imports the existing local installation package
Scratch crawler framework
Draw circuit diagram according to Verilog code
Chapter I Marxist philosophy is a scientific world outlook and methodology
Leetcode234 question - simple method to judge palindrome linked list
论文缩小
Penetration test - dry goods | 80 + network security interview experience post (interview)
Flask connects to existing tables in MySQL database
Axure install Icon Font Catalog
The solution to the memory exhaustion problem when PHP circulates a large amount of data
QT (VI) value and string conversion
Coding skills - Global exception capture & unified return body & Business exception
Easy to understand, distinguish between ++i and I++