title: Using a Zend_Db Database connection
body: <p>I'm trying to teach myself the Zend Framework. I have some extensive experience using custom-frameworks but have never used Zend.  It's like trying to use a knife and fork with mittens on.</p>
  
  <p>I've got a system up and running.  A database connection is being created in the applition.ini file without errors.</p>
  
  <p>The point I'm at is trying to use this connection to the database to execute basic SQL.  The application.ini has the lines:</p>
  
  <pre><code>db.adapter      = PDO_MYSQL
  db.params.host  = localhost
  db.params.username = cpanel_dbuser
  db.params.password = 123456
  db.params.dbname   = cpanel_dbname
  </code></pre>
  
  <p>I'm trying to connect to the database in my /public/index.php </p>
  
  <pre><code>$config = new Zend_Config_Ini(APPLICATION_PATH . 
                                '/configs/application.ini', 'production');
  $application-&gt;db = Zend_Db::factory($config-&gt;db);
  Zend_Db_Table::setDefaultAdapter($db);
  </code></pre>
  
  <p>The error I get is:</p>
  
  <pre><code>Fatal error:  Uncaught exception 'Zend_Db_Exception' with message 'Adapter name must be specified in a string' in /home/path/library/Zend/Db.php:226
  Stack trace:
  #0 /home/path/public/index.php(32): Zend_Db::factory(Array)
  #1 {main} thrown in /home/path/library/Zend/Db.php on line 226
  </code></pre>
  
  <p>And if I print_r the Config Object</p>
  
  <pre><code>Zend_Config Object
  (
      [_allowModifications:protected] =&gt; 
      [_index:protected] =&gt; 0
      [_count:protected] =&gt; 2
      [_data:protected] =&gt; Array
          (
              [adapter] =&gt; PDO_MYSQL
   /* ... more stuff ... */
  </code></pre>
  
  <p>From my understanding of the tutorials &amp; PDF's I'm working from, if I get this connection working I'll be able to do such fantastical amazements as the following from within a controller's indexAction </p>
  
  <pre><code> $data = $this-&gt;db-&gt;fetchAll(‘SELECT * FROM table’);
   foreach ($data as $row) {
        echo $row[‘table_fieldname’];
   }
  </code></pre>
  
  <p>And then start writing models for the tables I have.</p>
  
  <p>At this point, there's a pretty serious temptation to cut-the-corner and do this the way I already know how, but that completely defeats the purpose of learning to work within the framework.</p>
  
  <p>Can anyone bridge the gap for me (or point me to a resource that can clear this up)?</p>