Mend MN relationship in Zend Framework 2

With beta 4 and the latest beta, DB-Feature-Implementation seems to be pretty much complete. There are several tutorials out there that describe how to handle a single database using the TableGateway template, but there seems to be no way to handle MN relationships.

In ZF1, we had findDependantRowset() on the TableGateway, which was dirty, as this is just the second database query, which is pretty much not always necessary.

In ZF2, I expected there was a way to have a good Joins mapping for certain models, but I cannot find anything in the code. Maybe I'm blind, maybe there really is nothing like that.

Have any of you been able to process joins and model everything together in ZF2? If yes, please be kind enough to come to me how to do this, hint to me at specific points in the documentation or link me some blog poster with whoever did it.

Thanks in advance guys!

+4
source share
1 answer

The obvious solution, if you need a general solution, is to use Doctrine ORM or Propel.

If you want to use Zend \ Db, then within the classes of your specific table gateway, you must write a specific method that extracts the correct rows from the linked table. This way you can make sure that SQL is optimized for the requested query.

+5
source

All Articles