当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- 使用jsDelivr加速你的网站
- Python 图片识别 OCR
- 动态规划——用二进制表示集合的状态压缩DP
- 获取树形菜单列表
- Adobe Prelude /Pl 2020软件安装包(附安装教程)
- Why do we need software engineering -- looking at a simple project
- Reflection on a case of bus card being stolen and swiped
- C language I blog assignment 03
- Count the frequency of letters in text (case insensitive)
- What do you think of the most controversial programming ideas?
猜你喜欢
随机推荐
Don't treat exceptions as business logic, which you can't afford
Do not understand the underlying principle of database index? That's because you don't have a B tree in your heart
30岁后,你还剩下什么?
建议患者自杀,OpenAI警告:GPT-3用于医疗目的风险太高
What is the relationship between low code vs model driven?
Stack bracket matching
Kubernetes服务类型浅析:从概念到实践
Reflection on a case of bus card being stolen and swiped
Web安全(一)---浏览器同源策略
[original] the influence of arm platform memory and cache on the real-time performance of xenomai
graph generation model
不懂数据库索引的底层原理?那是因为你心里没点b树
AFO
easyui dialog“缓存问题”
Thinkphp6中where条件中字段与字段比较条件的写法
laravel8更新之维护模式改进
Improvement of maintenance mode of laravel8 update
我是如何失去团队掌控的?
构造请求日志分析系统
某618大促项目的复盘总结









