i have php mvc application. 'm' has domain, mapper , factory layers, , these accessed via service layer.
often need generate list of id/value pairs html select box. date, have put queries in mappers , returned simple array, doesn't feel right. mappers storing , retrieving objects, right?
i don't want overhead of retrieving collection of objects, discard of goodness produce simple array. thinking moving queries service, perhaps having service dedicated lookups? mean have sql code in 2 places in application, feels neater.
is there better option?
since writing service layer filtering out correct collection of records while fetching them, call service functions directly controller. , service call mapper function retrieving , storing records.
e.g controller -> service -> mapper
this way code structure kept neat , following dry (don't repeat yourself) principle; there no need having sql queries @ 2 places.
Comments
Post a Comment