当前位置:网站首页>Writing method of field and field comparison condition in where condition in thinkphpp6
Writing method of field and field comparison condition in where condition in thinkphpp6
2020-11-07 20:56:00 【daydaydream】
When I was testing the system today, I suddenly found that the original effect was not normal , After carefully examining all the code, we found that :
StorePink::where('id',1)->whereColumn('pinkAccount','<','people')->inc('pinkAccount')->update()
The function of this code is to find the code StorePink Column in table pinkAccount Is less than people, But what this code prints out is :
SELECT * FROM
StorePinkWHERE id='1' AND `pinkAccount < people LIMIT 1
ThinkPHP When parsing out the original field people It's parsed into a string , So the statement reports an error .
resolvent
1 The correct way is as follows
Look at the next two pieces of code where The conditions are :
where('pinkAccount','>','people') // In this case, between fields, use > separate , Express > The following is the field value, not the field
where('pinkAccount',' > people') // Here is the > With the following fields , The comparison between fields
2 Use key words whereColumn( In this method ThinkPHP6 In the user's manual )
StorePink::where('id',$order['pink_id'])->whereColumn('pinkAccount','<','people')->inc('pinkAccount')->update()
Generated SQL The statement is as follows :
SELECT * FROM StorePink WHERE ( pinkAccount > people )
版权声明
本文为[daydaydream]所创,转载请带上原文链接,感谢
边栏推荐
- Insight -- the application of sanet in arbitrary style transfer
- Do not understand the underlying principle of database index? That's because you don't have a B tree in your heart
- Web安全(一)---浏览器同源策略
- 洞察——风格注意力网络(SANet)在任意风格迁移中的应用
- 什么都2020了,LINQ查询你还在用表达式树
- [C + + learning notes] how about the simple use of the C + + standard library STD:: thread?
- Practice of Xiaoxiong school development board: real equipment access of smart street lamp sandbox experiment
- Analysis of kubernetes service types: from concept to practice
- 来自不同行业领域的50多个对象检测数据集
- In the age of screen reading, we suffer from attention deficit syndrome
猜你喜欢
随机推荐
Kylin on Kubernetes 在 eBay 的实践
全网最硬核讲解计算机启动流程
密码学-尚硅谷
构造请求日志分析系统
Principles of websocket + probuf
Improvement of maintenance mode of laravel8 update
A detailed explanation of microservice architecture
websocket+probuf.原理篇
工作1-3年的程序员,应该具备怎么样的技术能力?该如何提升?
30岁后,你还剩下什么?
一次公交卡被“盗刷”事件带来的思考
来自不同行业领域的50多个对象检测数据集
Adobe Prelude /Pl 2020软件安装包(附安装教程)
AC86U kx上网
盘点那些争议最大的编程观点,你是什么看法呢?
The most hard core of the whole network explains the computer startup process
状态压缩:对动态规划进行降维打击
On the coverage technology and best practice of go code
Adobe Lightroom /Lr 2021软件安装包(附安装教程)
我们为什么需要软件工程——从一个简单的项目进行观察








