我必须在DPTable接口上添加辅助表。怎么可能?
例如,在以下代码中:
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();
}
}
使用hosted_plans表在上面的代码list_plan函数中。我必须在同一个类上添加另一个函数来从HostedPlanContentMapping中获取详细信息。我尝试用list_plan_features()做的。并调用下面的控制器:
$featurelist = new Application_Model_DbTable_PlanList();
$this->view->listfeature = $featurelist->list_plan_features();
但没有得到结果。
有人可以帮我吗?
答案 0 :(得分:0)
作为替代方案,如果愿意,您可以直接从Table对象调用DB适配器。如下所示:
$select = $this->getAdapter()->select();
$select->from($tableName);
$row = $this->getAdapter()->fetchAll($select);
希望有所帮助,