I’m wondering if I can use the Zend framework to retrieve additional dependent rows efficiently without resorting to a lot of custom code. I’ll use the Zend example of the Bugs database to translate to my problem:
$accountsTable = new Accounts();
$accountsRowset = $accountsTable->find(1234);
$user1234 = $accountsRowset->current();
$bugsReportedByUser = $user1234->findDependentRowset('Bugs');
However, in my case the Bugs Table would have additional dependents, which in this example could be BugReproduction. How would one retrieve these Reproductions (which have a many-to-1-Bugs).
It seems like very poor coding to foreach over the $bugsReportedByUser and fetch additional dependentRowsets to get the Reproductions. This would result in ‘n’-order queries, while one always wants a fixed number of queries per request.
This seems trivial with Joins, but I’ve not found a reasonable way to do so in the Zend ecosphere.
Well I’ve thought long and hard, but it boils down to the fundamental missing of the rowset-method->getDependentRowset. (Not to be mistaken with a Row (singular)->getDepedentRowset() )
So extending Zend_Db_Table_Row_Abtract, and use it in the example’s Bugs Table class by:
And have findDependentRowset($dependentTable) implemented in MyRowSet. A highlevel implementation would be:
$ids(array).bugsTable->find($ids)(relation could be found by using Zend_Db_Table_Relationship)