Answer the question
In order to leave comments, you need to log in
[kohana] What is the best thing to do when saving a record?
Good day, dear forum users:
To get data in the edit form, I use:
$main_dep = DB::select('main_dep_id')
->from('departments')
->where('id', '=', $id);
$one_department_o1 = ORM::factory('department')
->where('id', '=', $id)
->or_where('id', '=', DB::expr('('.$main_dep.')'))
->find_all();
$data = Arr::extract($_POST, array('abbreviation', 'name', 'user_id', 'main_dep', 'status',));
$one_department_o1->values($data)).
Call to undefined method Database_MySQL_Result::values()
…
if ($this->request->post())
{
$one_department_o2 = ORM::factory('department', $id);
$data = Arr::extract($_POST, array('abbreviation', 'name', 'user_id', 'main_dep', 'status',));
$one_department_o2->values($data);
…
Answer the question
In order to leave comments, you need to log in
$one_department_o2->abbreviation = $data['abbreviation'];
...
$one_department_o2->save();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question