Hello ZF List! I'm building my application using data mappers and service layers. My service layers simply proxy to the data mappers, with additional ACL checks. Currently, all of my SQL is handled through the mappers, and my service layers know nothing about the database.
I'm building a simple "archive" page for my blog posts, and I have a query that I could run that would return the years, months, and number of posts within the year/month period: SELECT YEAR(`created`) year, MONTH(`created`) month, COUNT(`id`) blogs FROM `blogs` WHERE `status` = 'published' GROUP BY year, month Since this query is run against the "blogs" table, it seems it would make sense to place this within the blog data mapper. But since it returns an array instead of a blog object or a blog collection object, it seems a little "out of place". Would it be part of the data mapper's responsibility to provide me this information, even though it's not "mapping" any data? Where does this query belong in a data mapper / service layer design? Additionally, if I need to join the users table to, for example, exclude posts written by users that have been banned, that seems to me more like application logic than data mapping logic. So maybe this belongs in the service layer? Another solution I had in mind was to always start the archive at a set year (say, 2009), and loop through the months to get a collection of blog posts within that month/year, and then increment the year until it reaches the current month/year. It's not as efficient as the single SQL query above, but it would get the job done. Any suggestions on how to accomplish this? -- Hector
