坚持使用zend_db_table + join

时间:2011-07-25 09:10:56

标签: zend-db-table zend-db-select

尝试了解使用Zend_Db_Table

我有一张这样的表:

然后我创建了类:

class table_1 extends Zend_Db_Table_Abstract
{
    protected $_name = 'table_1';
    protected $_primary = 't1_id';
    protected $_referenceMap    = array(
        'DepCard' => array(
            'columns'           => 't1_id',
            'refTableClass'     => 'table_2',
            'refColumns'        => 't2_t1'
        ),
        'Select1' => array(
            'columns' => array('t1_select1'),
            'refTableClass' => 'Select_1'
        ),
        'Select2' => array(
            'columns' => array('t1_select2'),
            'refTableClass' => 'Select_2'
        )
    );

}

class table_2 extends Zend_Db_Table_Abstract {
  protected $_dependentTables = array('table_1');
}
class Select_1 extends Zend_Db_Table_Abstract {
  protected $_dependentTables = array('table_1');
}
class Select_2 extends Zend_Db_Table_Abstract{
  protected $_dependentTables = array('table_1');
}

然后我想:

$table_1 = new table_1();
$data = $table_1->fetchAll();

包含所有依赖表。 有没有办法做到这一点?

1 个答案:

答案 0 :(得分:0)

查看Zend_Db_TableZend_Db_Table_Select的代码表明这是不可能的。它始终只在单个表上运行fetchAll