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
I just did it right now. You just leave :
$db['default']['dsn'] = '';
And set:
$db['default']['dbdriver'] = 'postgre';
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
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
I had the same problem. Try these steps
dsn
string add port=>5432
to your config array 'dbdriver' => 'postgres'
extension=php_pdo_pgsql.dll
In the file database.php
where it reads:
'dbdriver' => ' ',
Put the following argument:
'dbdriver' => 'pgsql',