如何比较laravel和postgres中的两个字段 [英] How to Compare two fields in laravel and postgres

查看:70
本文介绍了如何比较laravel和postgres中的两个字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试查询postgres db并每次都遇到SQL错误. 该查询是正确的,但是为什么现在可以正常工作?

I'm trying to query postgres db and get a SQL error every time. The query is correct, but why does it now work?

查询

Apireq::where('calls','<','maxcalls')->get();

错误

SQLSTATE [22P02]:整数的无效输入语法

SQLSTATE[22P02]: invalid input syntax for integer

字段类型都设置为bigint.

真奇怪.

推荐答案

您需要使用whereRaw而不是仅在where.这很奇怪,但是可以解决我认为是Laravel Bug的问题.

You need to use whereRaw instead of just where. It's weird, but it gets around the issue which I think is a Laravel Bug.

whereRaw('calls < maxcalls') 

这篇关于如何比较laravel和postgres中的两个字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆