当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
猜你喜欢
随机推荐
Web安全(一)---浏览器同源策略
全网最硬核讲解计算机启动流程
Analysis of kubernetes service types: from concept to practice
How Facebook open source framework simplifies pytorch experiment
是时候结束 BERTology了
模型预测准确率高达94%!利用机器学习完美解决2000亿美元库存难题
聊一聊数据库中的锁
从技术谈到管理,把系统优化的技术用到企业管理
Why do we need software engineering -- looking at a simple project
使用jsDelivr加速你的网站
不要把异常当做业务逻辑,这性能可能你无法承受
一万四千字分布式事务原理解析,全部掌握你还怕面试被问?
Annual salary of 900000 programmers is not as good as 3800 civil servants a month? How to choose between stability and high income?
Adobe media encoder /Me 2021软件安装包(附安装教程)
Improvement of maintenance mode of laravel8 update
什么都2020了,LINQ查询你还在用表达式树
What magic things can a line of Python code do?
建议患者自杀,OpenAI警告:GPT-3用于医疗目的风险太高
Python 图片识别 OCR
[original] the influence of arm platform memory and cache on the real-time performance of xenomai









