当前位置:网站首页>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
StorePink
WHERE 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]所创,转载请带上原文链接,感谢
边栏推荐
猜你喜欢
More than 50 object detection datasets from different industries
Principles of websocket + probuf
[original] the influence of arm platform memory and cache on the real-time performance of xenomai
深入web workers (上)
C language I blog assignment 03
聊聊Go代码覆盖率技术与最佳实践
Ubuntu下搜狗输入法的下载安装及配置
Improvement of maintenance mode of laravel8 update
数据库基本操作
Code Review最佳实践
随机推荐
CPU瞒着内存竟干出这种事
supervisor进程管理安装使用
On hiz buffer
是时候结束 BERTology了
Static + code block + polymorphism + exception
某618大促项目的复盘总结
Improvement of maintenance mode of laravel8 update
从技术谈到管理,把系统优化的技术用到企业管理
IDEA-项目未自动生成 .iml 文件
Do not understand the underlying principle of database index? That's because you don't have a B tree in your heart
一次公交卡被“盗刷”事件带来的思考
Adobe Prelude /Pl 2020软件安装包(附安装教程)
「混合云」会是云计算的下一个战场吗?
awk实现类sql的join操作
Why do we need software engineering -- looking at a simple project
虚拟DOM中给同一层级的元素设置固定且唯一的key为什么能提高性能
easyui dialog“缓存问题”
深入web workers (上)
AFO记
来自不同行业领域的50多个对象检测数据集