Zend Framework Relationships - findDependentRowset
- by Morten Nielsen
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