protected function insert() { $f = new ARSelectFilter(new EqualsCond(new ARFieldHandle('SearchLog', 'keywords'), $this->keywords->get())); $f->mergeCondition(new EqualsCond(new ARFieldHandle('SearchLog', 'ip'), $this->ip->get())); if (!ActiveRecordModel::getRecordCount(__CLASS__, $f)) { parent::insert(); $update = new ARUpdateFilter(); $update->addModifier('time', new ARExpressionHandle('NOW()')); $update->setCondition(new EqualsCond(new ARFieldHandle(__CLASS__, 'ID'), $this->getID())); ActiveRecordModel::updateRecordSet(__CLASS__, $update); } }
public function setSingleAddress() { $f = new ARUpdateFilter(new EqualsCond(new ARFieldHandle('OrderedItem', 'customerOrderID'), $this->order->getID())); $f->addModifier('OrderedItem.shipmentID', new ARExpressionHandle('NULL')); ActiveRecordModel::updateRecordSet('OrderedItem', $f); $this->order->isMultiAddress->set(false); $this->order->loadAll(); $this->order->mergeItems(); $this->order->resetShipments(); SessionOrder::save($this->order); $this->order->deleteRelatedRecordSet('Shipment'); return new ActionRedirectResponse('order', 'index'); }
public function updateCategoryCounters(ARUpdateFilter $catUpdate, Category $category) { if ($catUpdate->isModifierSet()) { $categoryPathNodes = $category->getPathNodeArray(Category::INCLUDE_ROOT_NODE); $catIDs = array(); foreach ($categoryPathNodes as $node) { $catIDs[] = $node['ID']; } $catIDs[] = $category->getID(); $catUpdate->setCondition(new INCond(new ARFieldHandle('Category', 'ID'), $catIDs)); ActiveRecordModel::updateRecordSet('Category', $catUpdate); } }
public function disableRecords(ARSelectFilter $filter) { if ($disable = $this->getDisableFieldHandle()) { $update = new ARUpdateFilter($filter->getCondition()); $update->addModifier($disable->toString(), 0); ActiveRecordModel::updateRecordSet($this->className, $update, $this->getReferencedData()); } }
public function getNextCurrency() { if (!($data = $this->loadRecord('SELECT * FROM ' . $this->getTablePrefix() . 'currency_types ORDER BY sort_order ASC'))) { return null; } if (!($currency = ActiveRecordModel::getInstanceByIDIfExists('Currency', $data['currency_iso_3'], false))) { $currency = Currency::getNewInstance($data['currency_iso_3']); $currency->rate->set($data['currency_value']); } $currency->isEnabled->set(true); if ($this->getConfigValue('CONF_DEFAULT_CURRENCY') == $data['CID']) { $f = new ARUpdateFilter(); $f->addModifier('Currency.isDefault', 0); ActiveRecordModel::updateRecordSet('Currency', $f); $currency->isDefault->set(true); } return $currency; }
/** * @role update */ public function move() { $page = StaticPage::getInstanceById((int) $this->request->get('id'), StaticPage::LOAD_DATA); // update parent if ($this->request->get('parent')) { $parent = StaticPage::getInstanceById((int) $this->request->get('parent'), StaticPage::LOAD_DATA); } else { $parent = null; } $page->parent->set($parent); $page->save(); // update order $f = new ARUpdateFilter(); if ($parent) { $f->setCondition(eq(f('StaticPage.parentID'), $parent->getID())); } else { $f->setCondition(new IsNullCond(f('StaticPage.parentID'))); } $f->addModifier('StaticPage.position', new ARExpressionHandle('position+2')); if ($this->request->get('previous')) { $previous = StaticPage::getInstanceById((int) $this->request->get('previous'), StaticPage::LOAD_DATA); $position = $previous->position->get(); $f->mergeCondition(gt(f('StaticPage.position'), $position)); $page->position->set($position + 1); } else { $previous = null; $page->position->set(1); } ActiveRecordModel::updateRecordSet('StaticPage', $f); $page->save(); return new JSONResponse(array(), 'success', $this->translate('_pages_were_successfully_reordered')); }