Symfony sfDoctrinePager with multiple tables

瘦欲@ 提交于 2019-12-13 02:51:38

问题


I was wondering how to get this to run. In my application I have a Category table and Product table. I need to have a pager which combines both Categories and Products for display in one list (first categories then products). Is there a way to get this going ? I tried left joining in the pager's query, but doesn't seem to do the trick.


回答1:


If you can write a doctrine query to return the complete list of what you want, then the pager will page it.

Not sure without a schema how you might write such a query, not even 100% sure what you want to do. But if you are trying to list products with related category info, then you'll be needing a join, else if you want a mixed list of categories and products, you'll probably be wanting a UNION query.

If you post a schema and a bit more info about what you are doing, can try to help you.




回答2:


What i did to solve this was to write my own pager which extended the sfDoctrinePager and the created methods which give results in an array from 2 queries. Had to do some extra writting but worked fine.



来源:https://stackoverflow.com/questions/2362327/symfony-sfdoctrinepager-with-multiple-tables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!