- Fetch `user` row in a front controller plugin.
- Fetch the same `user` row in the controller.
- Fetch the same `user` row during a Model call.
I have a couple different hacks to this problem.
- Store Zend_Db_Row in registry when you need to use it later.
- Store Zend_Db_Row as a static property in the Zend_Db_Table class.
- Write Row to cache.
I've created fetchRowRegistry() and fetchRowStatic() which use fetchRow() and fetchAll().
This works OK but it's difficult for other developers to remember and use these special methods. I would also prefer a simpler approach.
Michael DePetrillo
theman@michaeldepetrillo.com
Mobile: (858) 761-1605
www.michaeldepetrillo.com
On Sat, Aug 21, 2010 at 9:24 PM, Marko78 <marko.korhonen@gmail.com> wrote:
models here and there all over again during the request.
$contentModel = new Content_Model_Content; is been called in many places
during some request on my application. Only "design pattern" I use for
models is "fat models, thin controllers", so I try to write all operations
to my model instead of writing them to my controllers.
So I was thinking, am I wasting resources? Declaring the same class over and
over again in the same request. Should I have somekind of centralized stack
where to register my Models when needed and the next time the Model is
needed it could be get from this centralized stack?
没有评论:
发表评论