stublackett Posted July 13, 2011 Share Posted July 13, 2011 Hi Guys, I've hit a bit of a brick wall in converting an SQL Query into a suitable ORM Query The query is pretty complex even in SQL Terms, But I am looking at ways of collating this into an ORM Query, as I'm converting a lot of functions I've produced in Flex into Zend Framework Models for future proofing and API Purposes. The current flat SQL is as follows : SELECT subcategory_id, SUM(total) / (1+(YEAR(2011)*12+MONTH(1))-(YEAR(2011)*12+MONTH(12))) AS monthly_average FROM aggr_subcategory WHERE user_id=1 AND month BETWEEN 01 AND 05 GROUP BY user_id, subcategory_id The main issues I am having are the SUM, I can manage the GROUP and WHERE clauses in ORM, but cannot get the sum in the DB Table Abstract. Any help or points in the right direction much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/241893-zend-framework-db-table-abstract/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.