I am looking for some input about best practices in models/controllers.
The application is still pretty simple, but i would like to make it right from the beginning. I have two actions:
1) I have to select a specified subscriber that is active ( active = 1 in database )
2) I have to select a specified subscriber, it does not matter if active or not.
My initial approach was this in controller:
$model = new Model_Subscriber();
$model->fetchAll(array(
'email = ?' => $email,
'active = 1'
));
I soon realized that this is bad since i am writing SQL and business logic in controller. So i created two functions in model:
1) getActiveSubscriberQuery($email)
2) getSubscriberQuery($email)
Both return a Zend_Db_Select, which i can use in fetchAll().
My question: Is this the best way to do things? I mean, yhe application might get complex and i am worried about having lots and lots of functions for each type of query in model.
Regards,
Fernando Morgenstern
contato@fernandomarcelo.com
没有评论:
发表评论