【发布时间】:2014-04-16 08:49:25
【问题描述】:
我习惯使用 mysql(i) 进行 Codeigniter,但我有一个客户需要连接 PostgreSQL。我尝试了通常的设置并为 Postgre 添加了特定的端口,但我得到了这个错误:
Unable to connect to your database server using the provided settings.
我的代码是这样的:
$active_group = (ENVIRONMENT == 'development') ? 'offline' : 'online';
//Set to 'development' in file: index.php
$active_record = TRUE;
/**
* OFFLINE CONFIGURATION
*/
$db['offline']['hostname'] = 'localhost';
$db['offline']['username'] = 'root';
$db['offline']['password'] = 'root';
$db['offline']['database'] = 'testing';
$db['offline']['dbdriver'] = 'postgre';
$db['offline']['dbprefix'] = '';
$db['offline']['pconnect'] = TRUE;
$db['offline']['db_debug'] = TRUE;
$db['offline']['cache_on'] = FALSE;
$db['offline']['cachedir'] = '';
$db['offline']['char_set'] = 'utf8';
$db['offline']['dbcollat'] = 'utf8_general_ci';
$db['offline']['swap_pre'] = '';
$db['offline']['autoinit'] = TRUE;
$db['offline']['stricton'] = FALSE;
$db['offline']['port'] = 5432;
/**
* ONLINE CONFIGURATION
*/
$db['online']['hostname'] = '?';
$db['online']['username'] = '?';
$db['online']['password'] = '?';
$db['online']['database' ....
//Continues with online configuration...
现在我正在使用offline 配置,但无法显示上述错误。我确实尝试将“db_debug”设置为 FALSE,这很有效,但我觉得这只是在跳过重点,我永远不会在离线模式下显示我需要的数据库错误...
我打开了pgAdmin 并连接到同一个数据库并且工作正常。有什么提示吗?
【问题讨论】:
标签: php codeigniter postgresql