protected function insert() { if (is_null($this->position->get())) { $this->setLastPosition('type'); } parent::insert(); }
protected function insert() { // get max position $f = new ARSelectFilter(); $f->setCondition($this->getParentCondition()); $f->setOrder(new ARFieldHandle(get_class($this), 'position'), 'DESC'); $f->setLimit(1); $rec = ActiveRecord::getRecordSetArray(get_class($this), $f); $position = is_array($rec) && count($rec) > 0 ? $rec[0]['position'] + 1 : 1; $this->position->set($position); return parent::insert(); }
protected function insert() { if (!$this->deliveryZone->get() || $this->deliveryZone->get()->isDefault()) { $this->deliveryZone->setNull(); } return parent::insert(); }
/** * Inserts new product record to a database * */ protected function insert() { ActiveRecordModel::beginTransaction(); try { $this->dateCreated->set(new ARSerializableDateTime()); $this->dateUpdated->set(new ARSerializableDateTime()); parent::insert(); if ($this->category->get()) { $this->updateCategoryCounters($this->getCountUpdateFilter(), $this->category->get()); } ActiveRecordModel::commit(); } catch (Exception $e) { ActiveRecordModel::rollback(); throw $e; } }
protected function insert() { $this->setLastPosition(); parent::insert(); }
protected function insert() { // get current max position if (!$this->position->get()) { $filter = new ARSelectFilter(); $cond = new EqualsCond(new ARFieldHandle(get_class($this), $this->getFieldIDColumnName()), $this->getField()->get()->getID()); $filter->setCondition($cond); $filter->setOrder(new ARFieldHandle(get_class($this), 'position'), 'DESC'); $filter->setLimit(1); $res = ActiveRecordModel::getRecordSet(get_class($this), $filter); if ($res->size() > 0) { $item = $res->get(0); $pos = $item->position->get() + 1; } else { $pos = 0; } $this->position->set($pos); } return parent::insert(); }
protected function insert($foreignKeyName) { $className = get_class($this); // get current max image position $filter = new ARSelectFilter(); $filter->setCondition(new EqualsCond(new ARFieldHandle($className, $foreignKeyName), $this->getOwner()->getID())); $filter->setOrder(new ARFieldHandle($className, 'position'), 'DESC'); $filter->setLimit(1); $maxPosSet = ActiveRecord::getRecordSet($className, $filter); if ($maxPosSet->size() > 0) { $maxPos = $maxPosSet->get(0)->position->get() + 1; } else { $maxPos = 0; } $this->position->set($maxPos); return parent::insert(); }
protected function insert() { $this->setLastPosition('category'); return parent::insert(); }
protected function insert() { if ($this->shipment->get() && !$this->shipment->get()->isExistingRecord()) { $this->shipment->setNull(); } if (!$this->price->get()) { $this->price->set($this->getProduct()->getItemPrice($this)); } return parent::insert(); }