2012-02-15 50 views
0

我必須在DPTable接口上添加輔助表。這怎麼可能?zend多表接口

例如在下面的代碼:

class Application_Model_DbTable_PlanList extends Zend_Db_Table_Abstract 
{ 

protected $_name = 'hosted_plans'; 

public function list_plan() 
{ 
    $row = $this->fetchAll(); 
    if (!$row) 
    { 
     throw new Exception("Could not find row $id"); 
    } 
    return $row->toArray(); 
} 
public function list_plan_features() 
{ 

     $table = new HostedPlanContentMapping(); 

     $select = $table->select(); 
     $select->from($table); 
     $row = $table->fetchAll($select); 


    if(!$row) 
    { 
     throw new Exception("Could not find result"); 
    } 
    return $row->toArray(); 


} 
} 

在上述代碼list_plan功能使用hosted_plans表。我必須在同一個類上添加另一個函數來從HostedPlanContentMapping中獲取細節。我試圖用list_plan_features()做。並調用如下控制器:

$featurelist = new Application_Model_DbTable_PlanList(); 
$this->view->listfeature = $featurelist->list_plan_features(); 

但沒有得到結果。

有人能幫助我嗎?

回答

0

作爲一種替代方法,您可以隨時直接從Table對象調用數據庫適配器,如果您願意的話。像下面這樣:

$select = $this->getAdapter()->select(); 
    $select->from($tableName); 
    $row = $this->getAdapter()->fetchAll($select); 

希望幫助,