当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- How Facebook open source framework simplifies pytorch experiment
- 使用 Xunit.DependencyInjection 改造测试项目
- 尾-递
- 浅谈HiZ-buffer
- 30岁后,你还剩下什么?
- 不懂数据库索引的底层原理?那是因为你心里没点b树
- 洞察——风格注意力网络(SANet)在任意风格迁移中的应用
- Analysis of kubernetes service types: from concept to practice
- 获取树形菜单列表
- use Xunit.DependencyInjection Transformation test project
猜你喜欢
Summary of the resumption of a 618 promotion project
Let's talk about the locks in the database
密码学-尚硅谷
A detailed explanation of microservice architecture
Annual salary of 900000 programmers is not as good as 3800 civil servants a month? How to choose between stability and high income?
盘点那些争议最大的编程观点,你是什么看法呢?
Code Review最佳实践
年薪90万程序员不如月入3800公务员?安稳与高收入,到底如何选择?
Don't treat exceptions as business logic, which you can't afford
什么都2020了,LINQ查询你还在用表达式树
随机推荐
Code Review Best Practices
在 Amazon SageMaker 管道模式下使用 Horovod 实现多 GPU 分布式训练
Why do we need software engineering -- looking at a simple project
浅谈HiZ-buffer
统计文本中字母的频次(不区分大小写)
What do you think of the most controversial programming ideas?
Implementation of Caesar cipher
Sentry 安装
留给快手的时间不多了
大数据算法——布隆过滤器
Kubernetes服务类型浅析:从概念到实践
一万四千字分布式事务原理解析,全部掌握你还怕面试被问?
来自不同行业领域的50多个对象检测数据集
密码学-尚硅谷
DOM节点操作
是时候结束 BERTology了
手撕算法-手写单例模式
[C + + learning notes] how about the simple use of the C + + standard library STD:: thread?
Web安全(三)---CSRF攻击
Web安全(二)---跨域资源共享