我通过PostgreSQL连接器使用Redshift,在php codeigniter 3中查询时出现以下错误。x,php版本7.0模型如下
$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'附加在值之前,如下所示
错误:类型“e”不存在
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”引起了所有的麻烦,任何人有什么建议请回答。我是新来的,不知道是什么原因,我已经添加了以下信息。
php版本:7.0 codeigniter:3.操作系统:Centos 6.9
2条答案
按热度按时间qxgroojn1#
这个E是PostgreSQL中的转义字符。看这里。
尝试为
where_in
添加第三个参数,以避免转义。qzlgjiam2#
我在使用SQL Workbench连接到AWS Redshift时也遇到了这个错误。
当您使用Postgres JDBC驱动程序(org.postgresql.Driver)连接到Redshift。相反,您应该使用Redshift JDBC驱动程序(com.amazon.redshift.司机).看到-这个
当我使用Redshift驱动程序时,问题得到了解决。