Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql Laravel Eloqeunt CAST()表列的postgres生成错误_Postgresql_Laravel - Fatal编程技术网

Postgresql Laravel Eloqeunt CAST()表列的postgres生成错误

Postgresql Laravel Eloqeunt CAST()表列的postgres生成错误,postgresql,laravel,Postgresql,Laravel,我在Postgres中使用Laravel5.2。我有一个整数列,需要在其中放入一个条件,例如%%。我有一个保存整数值的邮政编码列。现在,我需要得到所有包含12的行。但我们不能用整型数据类型,所以我在执行查询时将其转换为文本,但我得到了错误 这是我的密码 $query->where("cast(postal_code as TEXT)", "LIKE", "%".$request['postal_code']. "%"); 它正在产生错误 "cast(postal_code" as "te

我在Postgres中使用Laravel5.2。我有一个整数列,需要在其中放入一个条件,例如
%%
。我有一个保存整数值的邮政编码列。现在,我需要得到所有包含
12
的行。但我们不能用整型数据类型,所以我在执行查询时将其转换为文本,但我得到了错误

这是我的密码

$query->where("cast(postal_code as TEXT)", "LIKE", "%".$request['postal_code']. "%");
它正在产生错误

"cast(postal_code" as "text)"

请查看将不需要的
放在查询中。这是查询输出错误。这是错误还是有其他问题,以及如何修复该错误。

我认为在laravel中的何处设置字段似乎不起作用。使用whereRaw函数执行原始查询

$query->WhereRaw("cast(postal_code as TEXT) ILIKE '%?%',[$request['postal_code']]");