问题描述
我在通过Postgresql连接器使用Redshift时,在php codeigniter 3.x,php 7.0版中查询时遇到以下错误模型如下
i'm using Redshift through Postgresql connector i got the following error while querying in php codeigniter 3.x, php version 7.0the model is as follows
$subQuery = "select max(button_history_id) as button_history_id from button_history
where site_id =".$site_id." group by button_history_id ";
$this->another->select('cms_group_id');
$this->another->from('button_history');
$this->another->where('button_history_id IN ('.$subQuery.")");
$this->another->where('cms_group_id !=', '');
$queryGrp = $this->another->get();
$grpIds = array();
foreach($queryGrp->result_array() as $grps){
if($grps['cms_group_id'])
$grpIds = array_merge($grpIds,explode(',', $grps['cms_group_id']));
}
if($grpIds){
$grpIds = array_unique($grpIds);
$this->another->select('content_history_id, (content_id),content_name,content_type');
$this->another->from('content_history');
$this->another->where_in('content_id',$grpIds);
$this->another->group_by('content_history_id,content_id,content_name,content_type');
$this->another->order_by('content_id ,content_history_id',"desc");
$queryG = $this->another->get();
$result1 = $queryG->result_array();
}
但在以下值之前会附加一个不需要的E'
but an unwanted E' is appending before the values as follows
错误:类型"e"不存在
ERROR: type "e" does not exist
SELECT "content_history_id", (content_id), "content_name", "content_type" FROM "content_history" WHERE "content_id" IN( E'358', E'357', E'359', E'361', E'408', E'398', E'362', E'366', E'363') GROUP BY "content_history_id", "content_id", "content_name", "content_type" ORDER BY "content_id" DESC, "content_history_id" DESC
此E'358'"E"造成了所有麻烦,如果有人有任何建议,请回复.我是新来的,不知道是什么共振,我在下面添加了信息.
this E'358' "E" is causing all the trouble , could anyone has any suggestions please respond. i'm new to this, and hv no idea what is the reson, i have added th info below.
php版本:7.0codeigniter:3.x操作系统:Centos 6.9
php version :7.0codeigniter :3.xOS: Centos 6.9
推荐答案
此E用于在PostgreSQL中转义字符.请参见此处
This E is for escaping character in PostgreSQL. See here.
尝试在where_in
中添加第三个参数,以避免转义.
Try to adding a third parameter to where_in
, which avoid escaping.
$this->another->where_in('content_id',$grpIds, false);
这篇关于输入"e"不存在,通过php codeigniter中的Postgresql连接器进行Redshift的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!