title: Zend Framework ORM-style table data gateway vs. extending Zend_Db_Table_Abstract
body: <p>In the <a href="http://framework.zend.com/docs/quickstart/create-a-model-and-database-table" rel="noreferrer">Zend Framework Quickstart</a>, there has been a change from models that extend <code>Zend_Db_Table_Abstract</code> to the Table Data Gateway pattern.</p>
  
  <p>Personally, I have not had much experience with this pattern and I keep hearing this should most likely be used instead of the old way.</p>
  
  <p><strong>A short example from the quickstart:</strong></p>
  
  <p><em>Old way:</em></p>
  
  <pre><code>class Default_Model_Guestbook extends Zend_Db_Table_Abstract
  {
      protected $_name = 'tablename';
  
      // do stuff
  }
  </code></pre>
  
  <p><em>New way:</em></p>
  
  <pre><code>// The actual model
  class Default_Model_Guestbook
  {
      protected $_comment;
      protected $_created;
      protected $_poster;
      // list continues with all columns
  }
  
  // Dbtable for this model
  class Default_Model_DbTable_Guestbook extends Zend_Db_Table_Abstract
  {
      /** Table name */
      protected $_name    = 'guestbook';
  }
  
  // Mapper 
  class Default_Model_GuestbookMapper
  {
      public function save($model);
      public function find($id, $model);
      public function fetchAll();
  }
  </code></pre>
  
  <p>From my lacking experience with this style of programming, I find it hard to grasp the actual benefits from this latter way; I understand that this method seperates the database from the actual logic as much as possible, which should in theory make a transition to another database platform easier. However, I really don't see this happening on any project I am working.</p>
  
  <p>There is almost no doubt that I am overlooking something, so I'd love to hear your advice.</p>
  
  <p><strong>The question:</strong></p>
  
  <ul>
  <li><p><strong><em>Could someone please explain to me why (or if) the latter is better practice?</em></strong></p></li>
  <li><p><strong><em>Should I switch from the old way to the new way or are there still proper reasons for sticking with models that represent database tables?</em></strong></p></li>
  </ul>
  
  <p>Thanks in advance.</p>