2011-07-25 46 views
2

试图了解使用Zend_Db_Table卡住了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(); 

与所有相关表格。 有没有办法做到这一点?

回答

0

看着Zend_Db_Table's和Zend_Db_Table_Select的代码表明这是不可能的。它总是在单个表上运行fetchAll

+0

那么,唯一的办法就是让'class my_table_abstract扩展Zend_Db_Table_Abstract'和重载基类的功能?可能有简单的方法吗? – Subdigger