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

标签 php postgresql codeigniter amazon-redshift php-7

我通过 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

enter image description here

最佳答案

这个 E 用于 PostgreSQL 中的转义字符。请参阅here .

尝试向 where_in 添加第三个参数,以避免转义。

$this->another->where_in('content_id',$grpIds, false);

关于php - 类型 "e"不存在,通过 php codeigniter 中的 Postgresql 连接器进行 Redshift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52059812/

相关文章:

php - 字符串中的 HTML 中断标记在浏览器中显示为 <br>,但也显示为 <br> 开发控制台

php - URL 重写在末尾添加斜杠会破坏我的 css 链接

database - 在桌面 PostgreSQL 中使用 pg_read_file 读取文件

postgresql - 如何合并两个数据库副本(postgresql)

sql 表名、项目或项目

php - 无法访问与您的字段名称对应的错误消息

php - 如何接收动态文本框的post值

php - 实现Zend Framework是否需要修改现有的MySQL数据库?

javascript - PHP 字段输入随撇号变化

php - 在 codeigniter 中使用 PHP 导出表中的对象数组