具有多个表的 Symfony sfDoctrinePager

发布于 2024-08-23 02:28:36 字数 114 浏览 9 评论 0原文

我想知道如何让它运行。在我的应用程序中,我有一个类别表和产品表。我需要一个寻呼机,它将类别和产品组合在一起显示在一个列表中(第一个类别,然后是产品)。有办法让它继续下去吗?我尝试左加入寻呼机的查询,但似乎没有成功。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

混吃等死 2024-08-30 02:28:37

如果您可以编写一个学说查询来返回您想要的完整列表,那么寻呼机就会对其进行寻呼。

如果没有模式,不确定如何编写这样的查询,甚至不能 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.

请别遗忘我 2024-08-30 02:28:37

我为解决这个问题所做的就是编写自己的寻呼机,它扩展了 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文