Welcome Guest, Not a member yet? Register   Sign In
Model best practices
#1

[eluser]sqwk[/eluser]
Code:
// Just passing the whole lot to the create function
$this->my_model->create($data);

Is there any point/advantage in using a setter functions in a model instead of passing data directly to a create/update function?

Code:
// Setting data though predefined setter functions for protected vars.
$this->my_model->set_var1($var1)
               ->set_var2($var2)
               ->create();

// The create function would then loop through the $this object and set the various vars.
foreach ($this as $variable => $value)
    $this->db->set($variable, $value);
$this->db->insert('table');


Messages In This Thread
Model best practices - by El Forum - 07-11-2011, 09:19 PM
Model best practices - by El Forum - 07-11-2011, 10:28 PM
Model best practices - by El Forum - 07-12-2011, 07:03 AM
Model best practices - by El Forum - 07-12-2011, 07:11 PM
Model best practices - by El Forum - 07-12-2011, 07:42 PM
Model best practices - by El Forum - 07-12-2011, 07:50 PM
Model best practices - by El Forum - 07-12-2011, 07:51 PM
Model best practices - by El Forum - 07-12-2011, 08:01 PM
Model best practices - by El Forum - 07-12-2011, 08:08 PM
Model best practices - by El Forum - 07-12-2011, 08:11 PM
Model best practices - by El Forum - 07-12-2011, 08:29 PM
Model best practices - by El Forum - 07-12-2011, 08:30 PM
Model best practices - by El Forum - 07-12-2011, 08:35 PM
Model best practices - by El Forum - 07-12-2011, 08:39 PM
Model best practices - by El Forum - 07-13-2011, 11:12 PM
Model best practices - by El Forum - 07-14-2011, 01:35 AM



Theme © iAndrew 2016 - Forum software by © MyBB