ci 配置postgreSQL

ci 配置postgreSQL

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost',
    'username' => 'postgres',
    'password' => 'root',
    'database' => 'antto_wuzheng',
    'dbdriver' => 'postgre',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE,
    'port' => 5432
);

ci 连接postgreSQL,总是报错“Call to undefined function pg_connect()”

1、配置c:\windows目录下面的php.ini,去掉extension=php_pdo_pgsql.dll和extension=php_pgsql.dll之前的逗号 –亲测可用
2、安装pgAdmin III(1.18),下载地址:http://www.postgresql.org/ftp/pgadmin3/release/
3、在windows环境变量path中增加以下内容:D:\AppServ\php5\ext;D:\Program Files (x86)\pgAdmin III\1.18
说明:
之所以报错,是因为找不到对应的dll文件,因此在path中添加相应的dll文件加载进来是一个方法。
一个是appserv下php5的ext目录,一个是pgadmin的目录,如果不加到系统path路径中,则需要拷贝相应的文件到系统可识别的路径中,如c:\windows\system32下,由于需要拷贝的dll文件较多,不如直接加path路径好一些,这样不会漏掉。

pg_query(): Query failed: 错误: 操作符不存在:

smallint = boolean LINE 3: WHERE “deleted” = FALSE ^ HINT: 没有匹配指定名称和参数类型的操作符. 您也许需要增加明确的类型转换.
搜索字段类型和数据库字段类型不匹配,需要更改查询字段或者数据库字段类型,如 deleted int2 =>> change =>> deleted bool(0)

session 失效

// 如果使用数据库驱动,很可能是ci_sessions 表结构不对,用以下代码创建表即可
CREATE TABLE "ci_sessions" (
    "id" varchar(128) NOT NULL,
    "ip_address" varchar(45) NOT NULL,
    "timestamp" bigint DEFAULT 0 NOT NULL,
    "data" text DEFAULT '' NOT NULL
);

字段 “wuzheng_gui.id” 必须出现在 GROUP BY 子句中或者在聚合函数中使用

错误: 字段 “wuzheng_gui.id” 必须出现在 GROUP BY 子句中或者在聚合函数中使用 LINE 1: SELECT “id”, count(*) count ^

SELECT “id”, count(*) count FROM “wuzheng_gui” WHERE “wzg_id” = ‘3’ GROUP BY “site”

解决:去除 字段id, 如果需要id,则需要在group by 后添加,如:
SELECT count(*) count FROM “wuzheng_gui” WHERE “wzg_id” = ‘3’ GROUP BY “site”, “id”
OR
SELECT “id”, count(*) count FROM “wuzheng_gui” WHERE “wzg_id” = ‘3’ GROUP BY “site”, “id”
OR
SELECT “site”, count(*) count FROM “wuzheng_gui” WHERE “wzg_id” = ‘3’ GROUP BY “site”

836 total views, 6 views today

Revisions

There are no revisions for this post.

Comments are closed.