Zend Framework Relationships - findDependentRowset

Posted by Morten Nielsen on Stack Overflow See other posts from Stack Overflow or by Morten Nielsen
Published on 2010-05-18T07:16:15Z Indexed on 2010/05/18 7:20 UTC
Read the original article Hit count: 357

Hello,

When I call the method findDependentRowset, the returning rowset contains all the rows in the dependent table, and not only the rowsets that matches the reference.

Hoping someone could explain this, since I was of the assumption that findDependentRowset would only return rowset matching my 'rule'?

I have the following DbTable Models:

class Model_DbTable_Advertisement extends Zend_Db_Table_Abstract
{
    protected $_name = 'Advertisements';
    protected $_primary = 'Id';

    protected $_dependentTables = array (
        'Model_DbTable_Image',
    );
}

class Model_DbTable_Image extends Zend_Db_Table_Abstract
{
    protected $_name = 'Images';
    protected $_primary = 'Id';

    protected $_referenceMap = array(
        'Images' => array(
            'column' => 'AdvertisementId',
            'refColumn' => 'Id',
            'refTableClass' => 'Model_DbTable_Advertisement',
        )
    );

}

Now when i execute the following: (Simplified for Question sake)

$model = new Model_DbTable_Advertisement();
$rowSet = $model->fetchAll();
$row = $rowSet->current();
$dRow = $row->findDependentRowset('Model_DbTable_Image');

I would expect $dRow to only contain 'Images' that has the same advertisementId as $row, but instead i receive all rows in the Images table.

Any help appriciated.

Kind regards, Morten

© Stack Overflow or respective owner

Related posts about zend-framework

Related posts about zend-db-table