php - Is this a good way to structure model on an MVC application? -
this more "am doing right?" question.
i using mvc framework ( zend framework ) , wondering if best way structure model.
in case have user groups model and, after coding sometime, realized on controllers repeating stuff query return visible groups.
$model->fetchall( array( 'enabled = 1', 'visible = 1' ) );
in order reduce code repetition, created method on model returns query visible groups.
based on same situation, created many other methods hidden groups, disabled groups etc.
is best way avoid code duplication? concern if kept inserting code on controllers have big headache if business rule visible group changes in future.
at same time concerned that, if follow new approach, end bloated model full of methods return queries.
how deal kind of situation?
thanks help!
if u writing queries fetch data in controllers model layer of mvc then?. write seperate layer get, add, edit etc. domain models. u can have @ repository pattern in php here.
Comments
Post a Comment