当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- 如何高效的学习技术
- When tidb and Flink are combined: efficient and easy to use real-time data warehouse
- AFO
- static+代码块+多态+异常
- How Facebook open source framework simplifies pytorch experiment
- Static + code block + polymorphism + exception
- 低代码 vs 模型驱动,它们之间到底是什么关系?
- Cpp(三) 什么是CMake
- 工作1-3年的程序员,应该具备怎么样的技术能力?该如何提升?
- 计组-总线通信控制之异步串行通信的数据传输
猜你喜欢
随机推荐
Git code submission operation, and git push prompt failed to push some refs'xxx '
laravel8更新之维护模式改进
Practice of Xiaoxiong school development board: real equipment access of smart street lamp sandbox experiment
洞察——风格注意力网络(SANet)在任意风格迁移中的应用
聊聊Go代码覆盖率技术与最佳实践
When tidb and Flink are combined: efficient and easy to use real-time data warehouse
C language I blog assignment 03
The most hard core of the whole network explains the computer startup process
凯撒密码实现
Let's talk about the locks in the database
There's not much time left for Kwai Chung.
京淘项目day09
Thinkphp6中where条件中字段与字段比较条件的写法
Adobe Prelude /Pl 2020软件安装包(附安装教程)
我是如何失去团队掌控的?
快速上手Git
[漫谈] 软件设计的目标和途径
C语言I博客作业03
sed之查找替换
More than 50 object detection datasets from different industries