connecting postgresql and codeigniter

后端 未结 5 1962
北恋
北恋 2021-01-02 17:47

I\'m new using postgresql and I\'ve been using Codeigniter for a year.

I have a small postgresql database and I wanna call it from Codeigniter.

In my databas

相关标签:
5条回答
  • 2021-01-02 17:57

    I just did it right now. You just leave :

    $db['default']['dsn'] = '';
    

    And set:

    $db['default']['dbdriver'] = 'postgre';
    
    0 讨论(0)
  • 2021-01-02 18:05

    Remove the 'dsn' string and change to 'dbdriver' => 'postgre' in the config array.

    Despite the CI docs stating the value should be 'postgres' if you check the directory and file names in system>database>drivers the folder is actually called 'postgre', the file name 'postgre_driver.php' and the class 'CI_DB_postgre_driver' so we can assume the docs are wrong here. Weird this hasnt raised its ugly head before

    0 讨论(0)
  • 2021-01-02 18:11

    Try to set,

    dbdriver - The database type. ie: mysql, postgres, odbc, etc. Must be specified in lower case.

    More Info: https://www.codeigniter.com/user_guide/database/configuration.html

    EDIT: Try this config for PDO in postgres

    $db['default']['hostname'] = 'pgsql:host=localhost;dbname=yourdb'; //set host
    $db['default']['username'] = 'your username'; //set username
    $db['default']['password'] = 'your password'; //set password
    $db['default']['database'] = 'your database'; //set databse
    $db['default']['dbdriver'] = 'pdo'; //set driver here
    
    0 讨论(0)
  • 2021-01-02 18:11

    I had the same problem. Try these steps

    1. don't remove dsn string add port=>5432 to your config array
    2. set dbdriver to 'dbdriver' => 'postgres'
    3. check your php.ini file if postgre extension is enabled or not extension=php_pdo_pgsql.dll
    0 讨论(0)
  • 2021-01-02 18:15

    In the file database.php where it reads:

    'dbdriver' => ' ',
    

    Put the following argument:

    'dbdriver' => 'pgsql',
    
    0 讨论(0)
提交回复
热议问题