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.
Asked
Active
Viewed 1,313 times
1
-
May we take a look at code? Controller, view and anything related. And schema too. If you don't mind, I'd prefer http://gist.github.com/ – Andrei Dziahel Mar 02 '10 at 12:35
-
Ok so here's the deal ... pastebin.com/TyUQUVMt I've written the details below – karolsojko Mar 04 '10 at 10:26
2 Answers
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.

benlumley
- 11,370
- 2
- 40
- 39
-
Ok so here's the deal ... http://pastebin.com/TyUQUVMt If i go to a category page, I want a pager to be displayed with: - Selected Category's subcategories (first) - Selected Category's products (then) All in one pager. Basically results from two tables together in one pager and subcategories come first in the results. – karolsojko Mar 04 '10 at 10:26
-
I'd start by writing a doctrine query that can do this, or an sql one. You probably need to look at unions, and it may be a bit hacky as not sure that doctrine can handle one query returning two types of object maybe hydrating as an array will work though – benlumley Mar 07 '10 at 11:36
0
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.

karolsojko
- 711
- 1
- 8
- 27