0

我有这两个模型:

class Application_Model_List extends Zend_Db_Table_Abstract
{
    protected $_name = 'list';
    protected $_primary = 'list_id';
    protected $_dependentTables = array('Application_Model_Task');

    public function getUserLists($user)
    {
        $select = $this->select()->from($this->_name)->where('list_user = ?',$user);
        return $this->fetchAll($select);
    }

}

class Application_Model_Task extends Zend_Db_Table_Abstract
{
    protected $_name = 'task';
    protected $_primary = 'task_id';

    protected $_referenceMap = array(
        'List' => array(
            'columns'       => 'task_list_id',
            'refTableClass' => 'Application_Model_List',
            'refColumns'    => 'list_id'
        )
    );
}

getUserLists在我的控制器中这样调用:

public function indexAction()
{
    $lists = new Application_Model_List();
    $userLists = $lists->getUserLists(1);
    $this->view->lists = $userLists;
}

并将其传递给我的视图,然后findDependentRowset像这样调用:

foreach($this->lists as $list){
    echo $list->list_title;
    $tasks = $list->findDependentRowset('Application_Model_Task');
    foreach($tasks as $task){
        echo $task->task_title;
    }
}

但问题是它输出依赖表中的所有行集,而不仅仅是匹配 where 子句的行集

4

1 回答 1

0

哎呀。事实证明这是可行的,但无效的 HTML 隐藏了我期望的输出

于 2010-08-25T14:48:00.940 回答