title: Zend Framework: Get "invalid connection option "adapter" error when connecting to a PostgreSQL database
body: <p>I got this weird question which I cannot even find much answer online.</p>
  
  <p>The code is like this:</p>
  
  <pre><code>$config = new Zend_Config_Ini('../application/configs/application.ini',
                                APPLICATION_ENV);
  $db = Zend_Db::factory($config-&gt;resources-&gt;db-&gt;adapter,
                         $config-&gt;resources-&gt;db-&gt;params-&gt;toArray());
  $db-&gt;setFetchMode(Zend_db::FETCH_ASSOC);
  $db-&gt;query('set names utf8;');
  </code></pre>
  
  <p>Then I get error on the screen:</p>
  
  <pre><code>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-&gt;_connect()
  #1 /srv/uhg/ZF/library/Zend/Db/Adapter/Abstract.php(459): Zend_Db_Adapter_Pdo_Pgsql-&gt;_connect()
  #2 /srv/uhg/ZF/library/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract-&gt;query('set names utf8;', Array)
  #3 /srv/uhg/workspaces/zpe/library/Tls/Acl.php(72): Zend_Db_Adapter_Pdo_Abstract-&gt;query('set names utf8;')
  #4 /srv/uhg/workspaces/zpe/application/controllers/IndexController.php(12): Tls_Acl-&gt;__construct('developer')
  #5 /srv/uhg/ZF/library/Zend/Controller/Action.php(133): IndexController-&gt;init()
  #6 /srv/uhg/ZF/library/Zend/Controller/Dispatcher/Standard.php(268): Zend_Controller_Action-&gt;__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-&gt;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-&gt;dispatch()
  #9 /srv/uhg/ZF/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap-&gt;run()
  #10 /srv/uhg/workspaces/zpe/public/index.php(29): Zend_Application-&gt;run()
  </code></pre>
  
  <p>I also tried to omit what I get in the $config:</p>
  
  <p>PDO_PGSQL: the config things</p>
  
  <pre><code>Array ( [adapter] =&gt; PDO_PGSQL
          [host] =&gt; localhost 
          [username] =&gt; postgres
          [password] =&gt;
          [dbname] =&gt; uhg
          [default] =&gt; 1 )
  </code></pre>
  
  <p>When I searched this online, someone suggests I should unset <code>$config-&gt;resources-&gt;db-&gt;adapter</code> (of course after storing the value of it in somewhere), but when I tried so it suggests I cannot.</p>
  
  <p>It seems this only happens in postgresql, as it works fine with MySQL database.</p>
  
  <p>I am quite new to Posgresql, could this be problem of Postgresql?</p>
  
  <p>Someone shed a light please.</p>
  
  <p>Cheers.</p>
  
  <p>PS:</p>
  
  <p>For $db,  it exports(I replaced the real db name to xx-xxx):</p>
  
  <p>object(Zend_Db_Adapter_Pdo_Pgsql)#91 (12) { ["_pdoType":protected]=> string(5) "pgsql" ["_numericDataTypes":protected]=> array(12) { [0]=> int(0) [1]=> int(1) [2]=> int(2) ["INTEGER"]=> int(0) ["SERIAL"]=> int(0) ["SMALLINT"]=> int(0) ["BIGINT"]=> int(1) ["BIGSERIAL"]=> int(1) ["DECIMAL"]=> int(2) ["DOUBLE PRECISION"]=> int(2) ["NUMERIC"]=> int(2) ["REAL"]=> int(2) } ["_defaultStmtClass":protected]=> string(21) "Zend_Db_Statement_Pdo" ["_config":protected]=> array(10) { ["adapter"]=> string(9) "Pdo_Pgsql" ["host"]=> string(9) "localhost" ["username"]=> string(8) "postgres" ["password"]=> string(0) "" ["dbname"]=> string(3) "xxx-xxx" ["default"]=> string(1) "1" ["charset"]=> NULL ["persistent"]=> bool(false) ["options"]=> array(3) { ["caseFolding"]=> int(0) ["autoQuoteIdentifiers"]=> bool(true) ["fetchMode"]=> int(2) } ["driver_options"]=> array(0) { } } ["_fetchMode":protected]=> int(2) ["_profiler":protected]=> object(Zend_Db_Profiler)#92 (4) { ["_queryProfiles":protected]=> array(0) { } ["_enabled":protected]=> bool(false) ["_filterElapsedSecs":protected]=> NULL ["_filterTypes":protected]=> NULL } ["_defaultProfilerClass":protected]=> string(16) "Zend_Db_Profiler" ["_connection":protected]=> NULL ["_caseFolding":protected]=> int(0) ["_autoQuoteIdentifiers":protected]=> bool(true) ["_allowSerialization":protected]=> bool(true) ["_autoReconnectOnUnserialize":protected]=> bool(false) } </p>
  
  <p>!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</p>
  
  <p><strong>Thanks for everyone's help, I found a way to fix this :</strong></p>
  
  <pre><code>$db = new Zend_Db_Adapter_Pdo_Pgsql(array(
               'host' =&gt; 'localhost',  
              'username' =&gt; 'postgres',  
              'password' =&gt; '',  
              'dbname' =&gt; 'uhg'        
   ));
  </code></pre>