-
Get "invalid connection option "adapter" "error when connecting a postgresql database
Hi guys,
I got this weird question which I cannot even find much answer online.
The code is like this:
$config = new Zend_Config_Ini('../application/configs/application.ini', APPLICATION_ENV);
$db = Zend_Db::factory($config->resources->db->adapter, $config->resources->db->params->toArray());
$db->setFetchMode(Zend_db::FETCH_ASSOC);
$db->query('set names utf8;');
Then I get error on the screen:
An error occurred
Application error
Exception information:
Message: SQLSTATE[08006] [7] invalid connection option "adapter"
Stack trace:
#0 /srv/uhg/ZF/library/Zend/Db/Adapter/Pdo/Pgsql.php(87): Zend_Db_Adapter_Pdo_Abstract->_connect()
#1 /srv/uhg/ZF/library/Zend/Db/Adapter/Abstract.php(459): Zend_Db_Adapter_Pdo_Pgsql->_connect()
#2 /srv/uhg/ZF/library/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('set names utf8;', Array)
#3 /srv/uhg/workspaces/zpe/library/Tls/Acl.php(72): Zend_Db_Adapter_Pdo_Abstract->query('set names utf8;')
#4 /srv/uhg/workspaces/zpe/application/controllers/IndexController.php(12): Tls_Acl->__construct('developer')
#5 /srv/uhg/ZF/library/Zend/Controller/Action.php(133): IndexController->init()
#6 /srv/uhg/ZF/library/Zend/Controller/Dispatcher/Standard.php(268): Zend_Controller_Action->__construct(Object(Zend_Controller_Request_Http ), Object(Zend_Controller_Response_Http), Array)
#7 /srv/uhg/ZF/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#8 /srv/uhg/ZF/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#9 /srv/uhg/ZF/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#10 /srv/uhg/workspaces/zpe/public/index.php(29): Zend_Application->run()
I also tried to omit what I get in the $config:
PDO_PGSQL: the config things
Array ( [adapter] => PDO_PGSQL [host] => localhost [username] => postgres [password] => [dbname] => uhg [default] => 1 )
When I searched this online, someone suggests I should unset "$config->resources->db->adapter" (of course after storing the value of it in somewhere), but when I tried so it suggests I cannot.
It seems this only happens in postgresql, as it works fine with MySQL database.
I am quite new on Posgresql, could this be problem of Postgresql?
Someone shred a light please.
Cheers.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules