title: Can't connect to external database with Zend Framework but mysql_connect works
body: <p>I am trying to connect to multiple databases with Zend Framework. When I connect using the same credentials with mysql_connect, it works just fine. When I connect with Zend I get </p>
  
  <pre><code>"Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[28000] [1045] Access 
  denied for user 'xxxx'@'localhost' (using password: YES)' in C:\wamp\www\zend\library\Zend\Db\Adapter\Pdo\Abstract.php on line 144"
  </code></pre>
  
  <p>I was following the tutorial at <a href="http://www.amazium.com/blog/using-different-databases-with-zend-framework" rel="nofollow">http://www.amazium.com/blog/using-different-databases-with-zend-framework</a></p>
  
  <p>Here is my application.ini:</p>
  
  <pre><code>resources.multidb.db1.adapter = "PDO_MYSQL"
  resources.multidb.db1.dbname = "xxxxx"
  resources.multidb.db1.username = "xxxxxx"
  resources.multidb.db1.password = "xxxxxx"
  resources.multidb.db1.hostname = "localhost"
  resources.multidb.db1.charset = "UTF8"
  resources.multidb.db1.default = true
  
  resources.multidb.db3.adapter = "PDO_MYSQL"
  resources.multidb.db3.dbname = "xxxxxx"
  resources.multidb.db3.username = "xxxxxx"
  resources.multidb.db3.password = "xxxxxx"
  resources.multidb.db3.hostname = "xxxxx"
  resources.multidb.db3.charset = "UTF8"
  resources.multidb.db3.default = false
  </code></pre>
  
  <p>Here is my Bootstrap.php:</p>
  
  <pre><code>/**
   * Add databases to the registry
   */
  public function _initDbRegistry()
  {
      $this-&gt;bootstrap('multidb');
      $multidb = $this-&gt;getPluginResource('multidb');
      Zend_Registry::set('local', $multidb-&gt;getDb('db1'));
      Zend_Registry::set('db2', $multidb-&gt;getDb('db2'));
      Zend_Registry::set('db3', $multidb-&gt;getDb('db3'));
  }
  </code></pre>
  
  <p>Here is my model:</p>
  
  <pre><code>class ModuleName_Model_ModelName extends Zend_Db_Table_Abstract
  {
      protected $_name;
      protected $_schema;
      protected $_db; // changed from $_adapter in tutorial for Zend 1.11
  
      public function init() 
      {
          $this-&gt;_name = 'contacts';
          $this-&gt;_schema  = 'xxxxx';
          $this-&gt;_db = Zend_Registry::get('db3');
      }
  }
  </code></pre>
  
  <p>Here is where I'm calling it in my controller:</p>
  
  <pre><code>$model = new ModuleName_Model_ModelName();
  $this-&gt;view-&gt;output= $model-&gt;fetchAll();
  </code></pre>
  
  <p>I have connectected via phpmyadmin, mysql workbench, and using plain old mysql_connect by copying and pasting the same username and password. There is no doubt that the username and password are correct. Anyone have any idea what I could be doing wrong in Zend that is throwing the access denied error?</p>
  
  <p>Ok, thanks - I tried your suggestion, Midhun:</p>
  
  <pre><code>Zend_Debug::dump($model-&gt;getAdapter()-&gt;getConfig());
  </code></pre>
  
  <p>and I did get correct output.</p>
  
  <p>Any other ideas?</p>