Q: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?
A: $select->from(array('t1' => 'table1'))
->where("where");
->group("(field1) WITH ROLLUP");
$select->from(array('t1' => 'table1'))
->where("where");
->group("(field1) WITH ROLLUP");
本文探讨了在PHP与MySQL结合使用的环境中如何利用WITH ROLLUP实现查询结果的分组与子总计功能。虽然Zend_Db_Select不直接支持WITH ROLLUP,但通过示例代码展示了如何绕过这一限制。
667

被折叠的 条评论
为什么被折叠?



