Thursday, September 17, 2015

SQLSTATE[08006] [7] invalid connection option "adapter" Postgresql on Phalcon

In phalcon php framework, When you try to connect to PostgreSQL Database using configuration variables in config., you may write it as follows:
 
return new \Phalcon\Config(array(
    'database' => array(
        'adapter'     => 'Postgresql',
        'host'        => 'localhost',
        'username'    => 'postgres',
        'password'    => 'root',
        'dbname'      => 'mydb',
        'charset'     => 'utf8',
    ),....
 
 
if that is the case, you will get an error saying : invalid connection option "adapter" The problem here is that PostgreSQL configuration doesn't need the adapter key in the configuration array, also the charset key will produce the same error, So remove the two keys from the configuartion array:
  
return new \Phalcon\Config(array(
    'database' => array( ,
        'host'        => 'localhost',
        'username'    => 'postgres',
        'password'    => 'root',
        'dbname'      => 'mydb',
    ),....
 
 
The Second thing to do to assure that the database is connected, check to the services.php file and change the adapter to use postgresql instead of whatever been there (usually MySQL).
 
use Phalcon\Db\Adapter\Pdo\Postgresql as DbAdapter; 

No comments:

Post a Comment