如何在Magento ORM中使用聚合函数,如sum()、count()。
假设有一个名为“test”的表,其中包含以下值:
------------------------------------- productid | qty ------------------------------------- 1 | 2 ------------------------------------- 2 | 3 ------------------------------------- 3 | 5 -------------------------------------
如果我将此表映射到我的模块中,那么我可以像下面这样获取集合数据: $_collection = Mage::getModel('mymodule/customcart')->getCollection();
如何使用COLLECTION获得与以下查询等效的结果?
select sum(qty) from test;
假设有一个名为“test”的表,其中包含以下值:
------------------------------------- productid | qty ------------------------------------- 1 | 2 ------------------------------------- 2 | 3 ------------------------------------- 3 | 5 -------------------------------------
如果我将此表映射到我的模块中,那么我可以像下面这样获取集合数据: $_collection = Mage::getModel('mymodule/customcart')->getCollection();
如何使用COLLECTION获得与以下查询等效的结果?
select sum(qty) from test;