views:

220

answers:

1

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

A: 

The documentation seems to say that you may be misnaming some elements in your reference map for the second table. See if replacing the 'column' and 'refColumn' keys with 'columns' and 'refColumns', and then placing the string values into singleton arrays does the trick.

See http://framework.zend.com/manual/en/zend.db.table.relationships.html#zend.db.table.relationships.defining for more info

Robert Elwell