A have a lot of controllers where I must to save/create new models, it looks like this:
public Controller_Test extends Controller_Template {
if ($post = $this->request->post()) {
$model = ORM::factory('model');
$model->param1 = $post['Param1'];
$model->param2 = $post['Param26'];
$model->param3 = $post['Param31'];
$model->param4 = $post['Param13'];
$model->param5 = $post['Param2'];
$model->param6 = $post['Param35'];
$model->param7 = $post['Param10'];
$model->param8 = $post['Param22'];
$model->param9 = $post['Param3'];
$model->save();
}
}
Is it possible to unify (create a method) thats will save all array?
I know about $model->values($post)->create();
, but still can't understand how really same it works, as u can see I have different keys of posted parameteres and this might be considered.
In many examples all the data assignemnts take place in controller, but they're really small, in my case I'll suppose to have a huge controllers with a lot of data assignment strings and it will be a bad style coding I think.