当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- C语言I博客作业03
- 如何应对事关业务生死的数据泄露和删改?
- Python 图片识别 OCR
- android基础-RadioButton(单选按钮)
- IDEA-项目未自动生成 .iml 文件
- 你可能不知道的Animation动画技巧与细节
- 【C++学习笔记】C++ 标准库 std::thread 的简单使用,一文搞定还不简单?
- Dynamic programming -- state compression DP of set represented by binary
- Reflection on a case of bus card being stolen and swiped
- Insight -- the application of sanet in arbitrary style transfer
猜你喜欢
爆一个VS2015 Update1更新带来的编译BUG【已有解决方案】
Kubernetes服务类型浅析:从概念到实践
Design pattern of facade and mediator
From technology to management, the technology of system optimization is applied to enterprise management
【C++学习笔记】C++ 标准库 std::thread 的简单使用,一文搞定还不简单?
Git code submission operation, and git push prompt failed to push some refs'xxx '
30岁后,你还剩下什么?
laravel8更新之维护模式改进
Deep into web workers (1)
使用 Xunit.DependencyInjection 改造测试项目
随机推荐
Web安全(三)---CSRF攻击
Recommend suicide, openai warns: gpt-3 is too risky for medical purposes
Kylin on kubernetes' practice on eBay
一万四千字分布式事务原理解析,全部掌握你还怕面试被问?
Cpp(四) Boost安装及基本使用 for Mac
编程界大佬教你:一行Python代码能做出哪些神奇的事情?
Get started, GIT
[漫谈] 软件设计的目标和途径
微服务的出现和意义的探索
关于update操作并发问题
【解决方案】分布式定时任务解决方案
不懂数据库索引的底层原理?那是因为你心里没点b树
How to learn technology efficiently
Cpp(三) 什么是CMake
The instanceof operator in ecmascript7 specification
Insight -- the application of sanet in arbitrary style transfer
Cpp(二) 创建Cpp工程
从技术谈到管理,把系统优化的技术用到企业管理
How to deal with data leakage and deletion related to business life and death?
某618大促项目的复盘总结