How to connect CakePHP to Postgres database?

I am just starting out with CakePHP, I went through the blog tutorial without any problems, but now I would like to try it with a proper DBMS like postgres. I modified the database.php file to point to the database created in my local postgres instance:

class DATABASE_CONFIG {

    public $default = array(
        'datasource' => 'Database/Postgres',
        'persistent' => false,
        'host' => 'localhost',
        'port' => '5432',
        'login' => 'cakephp',
        'password' => 'cakephp',
        'database' => 'cakephp',
        'schema' => 'blog_tuto',
        'prefix' => '',
        //'encoding' => 'utf8',
    );

    public $test = array(
        'datasource' => 'Database/Postgres',
        'persistent' => false,
        'host' => 'localhost',
        'port' => '5432',
        'login' => 'cakephp',
        'password' => 'cakephp',
        'database' => 'cakephp',
        'schema' => 'blog_tuto',
        'prefix' => '',
        //'encoding' => 'utf8',
    );
}

I have no problem connecting to this database with an SQL client, but CakePHP complains about the following message:

CakePHP is NOT able to connect to the database.

Database connection "Postgres" is missing, or could not be created.
Selected driver is not enabled

I have already verified that the postgres DboSource class is present. Also installed php postgres module:

$ php -m | grep pg
pdo_pgsql
pgsql 

What am I missing? Thanks.

Update I : The phpinfo output associated with Postgres goes below:

pdo_pgsql
PDO Driver for PostgreSQL   enabled
PostgreSQL(libpq) Version   9.1.9
Module version  1.0.2
Revision    $Id: pdo_pgsql.c 321634 2012-01-01 13:15:04Z felipe $

pgsql
PostgreSQL Support  enabled
PostgreSQL(libpq) Version   9.1.9
Multibyte character support     enabled
SSL support     enabled
Active Persistent Links     0
Active Links    0

Directive   Local Value Master Value
pgsql.allow_persistent  On  On
pgsql.auto_reset_persistent Off Off
pgsql.ignore_notice Off Off
pgsql.log_notice    Off Off
pgsql.max_links Unlimited   Unlimited
pgsql.max_persistent    Unlimited   Unlimited

II. , Ajir, : " ", - , CakePHP . Postgres 9.3 ; , , SQL script, .

, , , Postgres 9.1.

+4
4

, , Postgres 9.1, Cake PHP Postgres 9.3. , :

  • , Postgres 9.1.

  • Postgres 9.3 ( ).

  • Postgres 9.3.

  • database.php Postgres 9.3 ( ).

  • Postgres 9.1 ( ).

0

:

sudo apt-get install php5-pgsql
+1

: Windows 7, IIS 7.5, php 5.3, postrgres 9.4, cakephp 2.6.3

:

extension=php_pgsql.dll extension=php_pdo_pgsql.dll

php.ini ( php.ini). , C:\Program Files (x86)\PHP\v5.3\ext ( php)

0

, blog_tuto, public, Postgresql. , blog_tuto public.

And in order to avoid encoding problems, I suggest you delete the comment of the encoding line and put the encoding that you use in your database (for example, UTF-8, LATIN1);

-1
source

All Articles