Friday, November 15, 2013

How to connect to a postgres database with CakePHP?

Hello everyone,

I'm just starting with CakePHP, I went through the blog tutorial without trouble but would now like to try it with a proper DBMS like postgres. I tweaked the database.php file to point to a database I created in my local postgres instance (see below). I have no issues connecting to this database with a SQL client, but CakePHP complains with 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

Apparently I need to enable the postgres driver (I already verifier that the postgres DboSource class in present), but so far I haven't found any instructions in the documentation on how to do it.

Any hints are welcome. Thanks.

----------------------------------------------------------------------------------

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',
    );
}

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: