0

私はこれらの2つのモデルを持っています:

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 に答える