当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
猜你喜欢
大数据算法——布隆过滤器
What do you think of the most controversial programming ideas?
From technology to management, the technology of system optimization is applied to enterprise management
Improvement of maintenance mode of laravel8 update
The CPU does this without the memory
WPF 关于绘图个人总结
AC86U kx上网
密码学-尚硅谷
状态压缩:对动态规划进行降维打击
【C++学习笔记】C++ 标准库 std::thread 的简单使用,一文搞定还不简单?
随机推荐
C language I blog assignment 03
How to think in the way of computer
快速上手Git
AFO
栈-括号的匹配
屏读时代,我们患上了注意力缺失候群症
use Xunit.DependencyInjection Transformation test project
Web安全(四)---XSS攻击
模型预测准确率高达94%!利用机器学习完美解决2000亿美元库存难题
盘点那些争议最大的编程观点,你是什么看法呢?
Stack bracket matching
C语言I博客作业03
Getting started with go wire dependency injection
编程界大佬教你:一行Python代码能做出哪些神奇的事情?
In the age of screen reading, we suffer from attention deficit syndrome
A detailed explanation of microservice architecture
洞察——风格注意力网络(SANet)在任意风格迁移中的应用
【C++学习笔记】C++ 标准库 std::thread 的简单使用,一文搞定还不简单?
Implementation of multi GPU distributed training with horovod in Amazon sagemaker pipeline mode
Don't treat exceptions as business logic, which you can't afford