function updatePosition() { $positionList = $this->input->post('positionList'); $idList = $this->input->post('idList'); $jobsmethods = new Jobsmethod(); for ($i = 0; $i < count($idList); $i++) { $jobsmethods->where("id", $idList[$i]); $jobsmethods->get(); $jobsmethods->position = $positionList[$i]; $jobsmethods->save(); $jobsmethods->clear(); } redirect("admin/jobsmethods/listAll/"); }
function save($object = '', $related_field = '') { if (!$this->exists()) { $o = new Jobsmethod(); $o->select_max('position'); $o->get(); if (count($o->all) != 0) { $max = $o->position + 1; $this->position = $max; } else { $this->postion = 1; } } return parent::save($object, $related_field); }