NYCPHP Meetup

NYPHP.org

[zendframework] findManyToManyRowset() without all the columns from match table?

David Mintz david at davidmintz.org
Mon Apr 19 10:24:06 EDT 2010


I tried this on the Zend list three days ago, no takers. So... suppose you
have

$rowset = $row->findManyToManyRowset('MyMatchTableClass',
'MyIntersectionTableClass');

but you don't want MyMatchTableClass.* (all columns from matching table) in
the resulting rowset, just a couple. I have seen examples showing how to
pass a $select with ORDER and LIMIT clauses (and have diddled around with
the $select to no avail), but I've found nothing regarding this particular
issue.

In my case, we have a many-to-many relationship between interpreters
(translators) and the "foreign" languages in which they work (English is
assumed). I am doing this in the controller:

$interps = new Model_DbTable_Interpreters;
$interpreter = $interps->find(1)->current();
$select = $interpreter->select();
$languages = $interpreter->findManyToManyRowset('Model_DbTable_Languages',
'Model_DbTable_InterpretersLanguages'
              ,null,null,$select->order('m.name ASC')
          );
Zend_Debug::dump($languages->toArray()); // all columns from languages table
are there

And ZF is doing this beneath the hood:

SELECT `m`.* FROM `interpreters_languages` AS `i` INNER JOIN `languages` AS
`m` ON `i`.`language_id` = `m`.`id` WHERE (`i`.`interpreter_id` = 1) ORDER
BY `m`.`name` ASC

Gratefully,

-- 
Support real health care reform:
http://phimg.org/

--
David Mintz
http://davidmintz.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/zendframework/attachments/20100419/f16f8a8d/attachment.html>


More information about the zendframework mailing list