代码是为连接而编写的,但函数 pg_connect() 不适用于框架和数据库,即 codeigniter 和 postgreSQL。
为了连接数据库,我已经为 config/database.php 编写了代码 但是连接无法连接的错误仍然存在。
我完成了 config/database.php 文件的信息 详细信息是完整的,并根据数据库连接的要求提供。
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => 'localhost',
'hostname' => 'localhost',
'username' => 'puneetchhabra',
'password' => 'shambhu',
'database' => 'success_story',
'dbdriver' => 'postgre',
'port' => '',
'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
);
错误信息
Severity: Warning
Message: pg_connect(): Unable to connect to PostgreSQL server: missing "=" after "localhost" in connection info string
Filename: postgre/postgre_driver.php
Line Number: 154
Unable to connect to your database server using the provided settings.
Filename: core/CodeIgniter.php
Line Number: 518
最佳答案
取出DSN。您通常应该使用参数数组或 DSN 字符串,而不是同时使用两者。
关于php - 我的数据库连接没有连接到 postgreSQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58299059/