title: Zend Db (standard or table gateway) vs Doctrine in Zend 2 - Pros/Cons
body: <p>Zend DB (standard way or table gateway) vs Doctrine in Zend 2.
  Some might say it’s apple vs orange comparison but I would say since they are substitutes (we use one between two) so it can be compared (as requirements are not always crystal clear).</p>
  
  <p>When I started Zend 2 since documentation, books, tutorials were based on Zend DB or Table Gateway, I used it but I was not happy with ways when we have to work on 2, 3 or more tables joins (multiple table gateway adapters) so I switched to Doctrine ORM (also reading so many saying “doctrine is good for large project”). I was already using doctrine in symfony projects so was not difficult but I also didn’t like doctrine in instance like complex joins between entities (extra works), especially slowness and extra memory compared to Zend DB.</p>
  
  <p>Now I am really confused what should I do? So what do you guys suggest?</p>
  
  <p>From my analysis:</p>
  
  <h1>Table Gateway</h1>
  
  <h3>Pros</h3>
  
  <ul>
  <li>Lightweight (keep things simple)</li>
  <li>Native to Zend (better support now and for future updates)</li>
  <li>More documentation-books</li>
  <li>Better community or user support (as it is what many are working on) </li>
  <li>Close of database-tables (I am good in SQL. So feel good)</li>
  <li>More flexible</li>
  <li>Easier to use other doctrine native features such as ACL</li>
  </ul>
  
  <h3>Cons:</h3>
  
  <ul>
  <li>Table joins (more complex)</li>
  <li>Primitive in some context</li>
  <li>Handling multiple table gateway instance is difficult.</li>
  </ul>
  
  <h1>Doctrine</h1>
  
  <h3>Pros</h3>
  
  <ul>
  <li>More classes-loosely coupled—better control</li>
  <li>Brings all advantages of using ORM</li>
  <li>Lots of work already on doctrine itself (tutorials-documentations) which works most of the time</li>
  <li>Less reliance on database</li>
  <li>Caching (but also possible with Zend DB Table Gateway)</li>
  </ul>
  
  <h3>Cons:</h3>
  
  <ul>
  <li>More memory and slower (compared to Zend DB Table Gateway) for medium project</li>
  <li>Adds complexity (extra files+ configurations + its own conventions)</li>
  <li>Sometimes overkill for medium projects</li>
  <li>More work in many to many relationships between entities or complicated joins</li>
  <li>Extra work YAML-Schema</li>
  <li>Less tutorials-books-user support on Zend + Doctrine</li>
  </ul>
  
  <p>Any others? ( for both)</p>
  
  <p>So, in light of these, which one do you suggest? Working on generic CMS that I can extend. </p>
  
  <p>or why Zend DB cannot/should not be used in larger projects?</p>
  
  <p>I found some discussion here but not as per its pros/cons analysis.</p>