具有多个表的 Symfony sfDoctrinePager
我想知道如何让它运行。在我的应用程序中,我有一个类别表和产品表。我需要一个寻呼机,它将类别和产品组合在一起显示在一个列表中(第一个类别,然后是产品)。有办法让它继续下去吗?我尝试左加入寻呼机的查询,但似乎没有成功。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您可以编写一个学说查询来返回您想要的完整列表,那么寻呼机就会对其进行寻呼。
如果没有模式,不确定如何编写这样的查询,甚至不能 100% 确定您想要做什么。但是,如果您尝试列出具有相关类别信息的产品,那么您将需要联接,否则,如果您想要类别和产品的混合列表,则可能需要 UNION 查询。
如果您发布架构和有关您正在做什么的更多信息,可以尝试为您提供帮助。
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.
我为解决这个问题所做的就是编写自己的寻呼机,它扩展了 sfDoctrinePager 和创建的方法,这些方法从 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.