codeigniter connect with postgresql database



代码是连接的,但数据库组无效,即 代码未与数据库连接,因为 database.php 文件中的设置无效。 我们在哪里查找错误以及如何解决此问题。

You have specified an invalid database connection group (db) in your config/database.php file.

此文件显示错误,但未指定错误的位置

config/database.php code below: 

$db['default'] = array(
'dsn'   => 'pgsql:host=localhost;port=5432;dbname=success_story',
'hostname' => 'localhost',
'username' => 'puneetchhabra',
'password' => 'shambhu',
'database' => 'success_story',
'dbdriver' => 'mysqli',
'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
);

数据库.php文件代码显示似乎是错误的内容。

浏览器出现此错误无法连接。

Message: pg_connect(): Unable to connect to PostgreSQL server: missing "=" `after "localhost" in connection info string`

善良并提出建议。

谢谢。

试试这个

$db['default'] = array(
'dsn'   => 'localhost',
'hostname' => 'localhost',
'username' => 'puneetchhabra',
'password' => 'shambhu',
'database' => 'success_story',
'dbdriver' => 'postgre', # or PDO
'port' => '' #ex 5433
);

确保

  1. 您可以在应用程序外部连接(pgadmin(
  2. 在 php 中.ini启用扩展php_pdo_pgsql(对于 pdo(和php_pgsql(对于 postgre(。

最新更新