当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
猜你喜欢

Annual salary of 900000 programmers is not as good as 3800 civil servants a month? How to choose between stability and high income?

团灭 LeetCode 股票买卖问题

What magic things can a line of Python code do?

How to choose a good company

技术总监7年自述——如何选择一家好公司

Code Review最佳实践

Using pipe() to improve code readability in pandas

密码学-尚硅谷

More than 50 object detection datasets from different industries

年薪90万程序员不如月入3800公务员?安稳与高收入,到底如何选择?
随机推荐
我们为什么需要软件工程——从一个简单的项目进行观察
[C + + learning notes] how about the simple use of the C + + standard library STD:: thread?
构造请求日志分析系统
Facebook开源框架如何简化 PyTorch 实验
30岁后,你还剩下什么?
Adobe Lightroom /Lr 2021软件安装包(附安装教程)
Practice of Xiaoxiong school development board: real equipment access of smart street lamp sandbox experiment
获取树形菜单列表
一文详解微服务架构
「混合云」会是云计算的下一个战场吗?
看一遍就理解,图解单链表反转
Kylin on Kubernetes 在 eBay 的实践
C language I blog assignment 03
Thinkphp6中where条件中字段与字段比较条件的写法
use Xunit.DependencyInjection Transformation test project
AC86U kx上网
On the coverage technology and best practice of go code
关于晋升全栈工程师,从入门到放弃的神功秘籍,不点进来看一看?
How did I lose control of the team?
如何应对事关业务生死的数据泄露和删改?