php - 我的数据库连接没有连接到 postgreSQL

标签 php postgresql codeigniter

代码是为连接而编写的,但函数 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/

相关文章:

php - DOMXPath 查询提取特定的 li 元素

php - Laravel 5 API 路线

postgresql - 前几行的累积数组?

php - 在一个查询中获取 5 个表数据......没有连接......没有关系

php - 如何在 Codeigniter 中选择无条件连接多个表?

php - 如何以这种格式将 MYSQLI 查询存储为多维数组

php - 如何循环获取过去十二个月开始和结束的 unix 时间?

postgresql - PostgisPG10Dialect 现在被 PostgreSQLDialect 取代了吗?

php - 如何使用 php 从结果列表中选择特定选项

php - 如何启用 instamojo 沙箱(测试模式)模式