title: Join with zend_db_table_abstract classes in Zend Framework
body: <p>I have a module with two models that extend Zend_Db_Table_Abstract:</p>
  
  <pre><code>class Departments_Model_Subpages extends Zend_Db_Table_Abstract
  {
      protected $_name = 'bktg_departments_subpages';
      protected $_primary = 'id';
  }
  
  class Departments_Model_Departments extends Zend_Db_Table_Abstract
  {
      protected $_name = 'bktg_departments';
      protected $_primary = 'id';
  }
  </code></pre>
  
  <p>Reading through the documentation, what I want to do is something like this (obviously, wrong):</p>
  
  <pre><code>$depTable = new Departments_Model_Departments();
  $subTable = new Departments_Model_Subpages();
  
  $depQuery = $depTable-&gt;select()-&gt;setIntegrityCheck(false)
  -&gt;from($depTable, array('id', 'title'))
  -&gt;join($subTable, array('COUNT(id) as `count`'))
  -&gt;where('bktg_departments.id = bktg_departments_subpages.parent_id');
  </code></pre>
  
  <p>What am I missing?  I just can't wrap my head around Zend joins, and I'm thinking I'm going to end up writing straight sql.</p>
  
  <p>Thank you for having a look.</p>
  
  <p>Edit</p>
  
  <p>Here's what I'm working with now:</p>
  
  <pre><code>$depQuery = $depTable-&gt;select()-&gt;setIntegrityCheck(false)
  -&gt;from($depTable, array('id', 'title'))
  -&gt;joinLeft($subTable, 'bktg_departments.id = bktg_departments_subpages.parent_id',       array('COUNT(id) as count'))
  -&gt;order('id DESC')
  -&gt;group('id');
  </code></pre>
  
  <p>The sql that works for me:</p>
  
  <pre><code>SELECT bktg_departments.id, bktg_departments.title, count(bktg_departments_subpages.id) FROM bktg_departments left join bktg_departments_subpages on bktg_departments.id = bktg_departments_subpages.parent_id group by bktg_departments.id
  </code></pre>
  
  <p>And I am having issues reproducing that in Zend.</p>