title: zend framework subquery
body: <p>I am using zend framework 1.12. I have following query to run. </p>
  
  <pre><code>"SELECT name,(select count(*) from  org_quote_template_items where org_quote_template_items.quote_template_id = org_quote_templates.`id` ) as total_line_item FROM `org_quote_templates`"
  </code></pre>
  
  <p>In my model file , I created it like this. following is my model file.</p>
  
  <pre><code>    class default_Model_DbTable_QuoteTemplates extends Zend_Db_Table_Abstract
  {
      /**
       * Name of the original db table
       *
       * @var string
       */
      protected $_name = 'org_quote_templates';
  
  
      public function getAllTemplate($where){
          $select = $this-&gt;select();        
          $subquery = " (SELECT COUNT(*) FROM  org_quote_template_items WHERE org_quote_template_items.quote_template_id = org_quote_templates.`id` )";
  
          $select-&gt;from(array($this), array('org_quote_templates.*','total_line_items' =&gt; new Zend_Db_Expr($subquery)));
  
          $select = $select-&gt;where('organization_id = ?',$where['org_id']);
  
          $adapter = new Zend_Paginator_Adapter_DbSelect($select);
          $paginator = new Zend_Paginator($adapter);
          $paginator-&gt;setItemCountPerPage(
                  Zend_Registry::get('config')-&gt;paginator-&gt;general);
          pr($adapter);
          exit;
      }
  }
  </code></pre>
  
  <p>I am getting following error when I run the code.
  " exception 'Zend_Db_Table_Select_Exception' with message 'Select query cannot join with another table' "</p>
  
  <p>please let me know what should I do ?</p>