Welcome Guest, Not a member yet? Register   Sign In
Generic Models & Views vs Bespoke Models and Views?
#1

[eluser]Mikeboy[/eluser]
Hello

1 - Generic Model vs Multiple Bespoke Models

For the particular application I am creating, all database queries are completed via stored procedures.

So could you therefore have one generic model class, and pass to it from the controller, the name of the procedure to execute, and the ID or names of the fields to return (if a select).

i.e.
Code:
$this->generic_model->add(sp_xxx_ins, $v1, $v2, $v3);
(= 'exec sp_xxx_ins $v1, $v2, $v3')

$this->generic_model->add(sp_xxx_del, $id);
(= 'exec sp_xxx_del $id')

$this->generic_model->add(sp_xxx_sel, $id, $name, $desc, $etc);
(= 'exec sp_xxx_sel $id' and then return the requested fields.)

Syntax may not be correct or the best way for passing the parameters, I haven't checked, but the idea is the same..

Is this a good way? It will cut out a lot of duplicated code. But is it generally best to have a 'model per table'?



2 - Generic View Template vs Multiple Bespoke Views

Different views - what is better:

1) Create multiple bespoke views with info such as forms, table headings, titles etc hard coded in them.

or

2) A single generic view template. Build up the dynamic data in the controller, i.e. build a form with the form helper, or create an array of table headings - and then pass this data into a generic view template?


What I am thinking is with the above ways you could have a few generic View templates (i.e. a generic table view, a generic form view, etc) and a single/or few generic Model. But then of course the controller may get quite large? Maybe the controller is doing some of the work that should be handled by the View ???


Please can someone advise the best direction to take? I want to make sure I am following the MVC structure as conventionally as possible.

Thanks Smile

Mike


Messages In This Thread
Generic Models & Views vs Bespoke Models and Views? - by El Forum - 07-23-2007, 12:09 PM
Generic Models & Views vs Bespoke Models and Views? - by El Forum - 07-23-2007, 07:24 PM
Generic Models & Views vs Bespoke Models and Views? - by El Forum - 07-28-2007, 04:11 PM
Generic Models & Views vs Bespoke Models and Views? - by El Forum - 07-29-2007, 02:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB