function save($object = '', $related_field = '') { if (!$this->exists()) { $o = new showroom(); $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); }
function up_position() { $max = new showroom(); $max->select_max('position'); $max->where('position <', $this->position); $max->get(); $o = new showroom(); $o->where('position', $max->position); $o->get(); if ($o->result_count() > 0) { $tg = $this->position; $this->position = $o->position; $o->position = $tg; $o->save(); $this->save(); return TRUE; } else { return FALSE; } }