类型“e”不存在,通过 php codeigniter 中的 Postgresql 连接器进行 Redshift

2024-03-06

我通过 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 代码点火器:3.x 操作系统:Centos 6.9


这个 E 在 PostgreSQL 中用于转义字符。看here https://www.postgresql.org/docs/9.0/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-ESCAPE.

尝试添加第三个参数where_in,避免逃逸。

$this->another->where_in('content_id',$grpIds, false);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

类型“e”不存在,通过 php codeigniter 中的 Postgresql 连接器进行 Redshift 的相关文章

随机推荐