当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- 是时候结束 BERTology了
- Cpp(一) 安装CMake
- The instanceof operator in ecmascript7 specification
- Insight -- the application of sanet in arbitrary style transfer
- 在 Amazon SageMaker 管道模式下使用 Horovod 实现多 GPU 分布式训练
- What is the relationship between low code vs model driven?
- go wire 依赖注入入门
- On hiz buffer
- 「混合云」会是云计算的下一个战场吗?
- CPU瞒着内存竟干出这种事
猜你喜欢
统计文本中字母的频次(不区分大小写)
来自不同行业领域的50多个对象检测数据集
Summary of the resumption of a 618 promotion project
How to choose a good company
Insight -- the application of sanet in arbitrary style transfer
CPU瞒着内存竟干出这种事
关于晋升全栈工程师,从入门到放弃的神功秘籍,不点进来看一看?
[original] the influence of arm platform memory and cache on the real-time performance of xenomai
三步一坑五步一雷,高速成长下的技术团队怎么带?
IDEA-项目未自动生成 .iml 文件
随机推荐
GrowingIO 响应式编程探索和实践
More than 50 object detection datasets from different industries
[original] the influence of arm platform memory and cache on the real-time performance of xenomai
构造请求日志分析系统
【解决方案】分布式定时任务解决方案
统计文本中字母的频次(不区分大小写)
微服务的出现和意义的探索
30岁后,你还剩下什么?
graph generation model
不懂数据库索引的底层原理?那是因为你心里没点b树
屏读时代,我们患上了注意力缺失候群症
ECMAScript7规范中的instanceof操作符
快速上手Git
WPF 关于绘图个人总结
分享几个我日常使用的VS Code插件
数据库基本操作
工作1-3年的程序员,应该具备怎么样的技术能力?该如何提升?
C language I blog assignment 03
Improvement of maintenance mode of laravel8 update
Count the frequency of letters in text (case insensitive)