The SQL query in my web application(PHP/MySQL + Zend) uses a number of parameters to build the search query. However, the records fetched should be grouped by two columns to get sub totals. WITH ROLLUP seems to be a good solution to find subtotals, but Zend_Db_Select doesn't support this modifier. Is there any work around?
Asked
Active
Viewed 1,542 times
1 Answers
6
Well,
$select->from(array('t1' => 'table1'))
->where("where");
->group("(field1) WITH ROLLUP");

S L
- 14,262
- 17
- 77
- 116
-
Thanks it worked. Actually I tried the same statement without parenthesis around the field name and it didn't worked. – libregeek Feb 03 '11 at 10:35
-
Caution: Do not use order() and group("(field1) with rollup") – libregeek Feb 03 '11 at 10:43