当前位置: 首页>>代码示例>>PHP>>正文


PHP ActiveRecord::getRecordSet方法代码示例

本文整理汇总了PHP中ActiveRecord::getRecordSet方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::getRecordSet方法的具体用法?PHP ActiveRecord::getRecordSet怎么用?PHP ActiveRecord::getRecordSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ActiveRecord的用法示例。


在下文中一共展示了ActiveRecord::getRecordSet方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setNextPosition

 public function setNextPosition()
 {
     $className = get_class($this);
     if (!is_integer(self::$nextPosition)) {
         $filter = new ARSelectFilter();
         $filter->setCondition(new EqualsCond(new ARFieldHandle($className, 'productID'), $this->product->get()->getID()));
         $filter->setOrder(new ARFieldHandle($className, 'position'), ARSelectFilter::ORDER_DESC);
         $filter->setLimit(1);
         self::$nextPosition = 0;
         foreach (ActiveRecord::getRecordSet($className, $filter) as $relatedProductGroup) {
             self::$nextPosition = $relatedProductGroup->position->get();
         }
     }
     $this->position->set(++self::$nextPosition);
 }
开发者ID:saiber,项目名称:www,代码行数:15,代码来源:ProductParametersGroup.php

示例2: testInstanceMemoryUsage

 public function testInstanceMemoryUsage()
 {
     $f = new ARSelectFilter();
     $f->setLimit(1000);
     ActiveRecord::getRecordSetArray('DiscountCondition', $f);
     $arrayMem = memory_get_usage();
     $array = ActiveRecord::getRecordSetArray('DiscountCondition', $f);
     $arrayMem = memory_get_usage() - $arrayMem;
     echo count($arrayMem) . "\n";
     echo $arrayMem . "\n";
     $arraySet = memory_get_usage();
     $array = ActiveRecord::getRecordSet('DiscountCondition', $f);
     $arraySet = memory_get_usage() - $arraySet;
     echo $arraySet . "\n";
 }
开发者ID:saiber,项目名称:www,代码行数:15,代码来源:MemoryUsageTest.php

示例3: testSerializeSpeed

 public function testSerializeSpeed()
 {
     for ($k = 1; $k <= 10; $k++) {
         $record = ActiveRecord::getNewInstance('SerializedModel');
         $record->setID($k);
         $record->name->set('some name ' . $k);
         $record->save();
     }
     ActiveRecord::clearPool();
     // fetch from database
     $fetchTime = microtime(true);
     $set = ActiveRecord::getRecordSet('SerializedModel', new ARSelectFilter());
     $fetchTime = microtime(true) - $fetchTime;
     $serialized = serialize($set);
     ActiveRecord::clearPool();
     // unserialize
     $serTime = microtime(true);
     $set = unserialize($serialized);
     $serTime = microtime(true) - $serTime;
     $this->assertTrue($serTime < $fetchTime);
 }
开发者ID:saiber,项目名称:www,代码行数:21,代码来源:SerializeTest.php

示例4: insert

 protected function insert()
 {
     // check currency symbol
     if (!$this->pricePrefix->get() && !$this->priceSuffix->get()) {
         $prefixes = (include ClassLoader::getRealPath('installdata.currency.signs') . '.php');
         if (isset($prefixes[$this->getID()])) {
             $signs = $prefixes[$this->getID()];
             $this->pricePrefix->set($signs[0]);
             if (isset($signs[1])) {
                 $this->priceSuffix->set($signs[1]);
             }
         }
     }
     // check if default currency exists
     if (!ActiveRecord::getRecordSet('Currency', select(eq('Currency.isDefault', 1)))->getTotalRecordCount()) {
         $this->isDefault->set(true);
         $this->isEnabled->set(true);
     }
     $this->setLastPosition();
     return parent::insert();
 }
开发者ID:saiber,项目名称:livecart,代码行数:21,代码来源:Currency.php

示例5: getCategoryImagesSet

 /**
  * Returns a set of category images
  *
  * @return ARSet
  */
 public function getCategoryImagesSet()
 {
     ClassLoader::import('application.model.category.CategoryImage');
     return ActiveRecord::getRecordSet('CategoryImage', $this->getCategoryImagesFilter());
 }
开发者ID:saiber,项目名称:www,代码行数:10,代码来源:Category.php

示例6: getCurrencySet

 private function getCurrencySet()
 {
     $filter = new ARSelectFilter();
     $filter->setCondition(new NotEqualsCond(new ARFieldHandle("Currency", "isDefault"), 1));
     $filter->setOrder(new ARFieldHandle("Currency", "isEnabled"), 'DESC');
     $filter->setOrder(new ARFieldHandle("Currency", "position"), 'ASC');
     return ActiveRecord::getRecordSet('Currency', $filter);
 }
开发者ID:saiber,项目名称:livecart,代码行数:8,代码来源:CurrencyController.php

示例7: loadData

 protected function loadData()
 {
     $this->data = ActiveRecord::getRecordSet($this->table, $this->filter, $this->referencedRecords)->getData();
 }
开发者ID:saiber,项目名称:www,代码行数:4,代码来源:ARInstanceFeed.php

示例8: loadCurrencyData

 /**
  * Loads currency data from database
  */
 private function loadCurrencyData()
 {
     $useCache = true;
     $cache = Currency::getCacheFile();
     if (file_exists($cache) && $useCache) {
         $this->currencies = (include $cache);
     } else {
         $filter = new ArSelectFilter();
         $filter->setCondition(new EqualsCond(new ArFieldHandle('Currency', 'isEnabled'), 1));
         $filter->setOrder(new ArFieldHandle('Currency', 'position'), 'ASC');
         $currencies = ActiveRecord::getRecordSet('Currency', $filter);
         $this->currencies = array();
         foreach ($currencies as $currency) {
             $this->currencies[$currency->getID()] = $currency;
         }
         if ($useCache) {
             file_put_contents($cache, '<?php return unserialize(' . var_export(serialize($this->currencies), true) . '); ?>');
         }
     }
     foreach ($this->currencies as $currency) {
         if ($currency->isDefault()) {
             $this->defaultCurrency = $currency;
         }
     }
 }
开发者ID:GregerA,项目名称:livecart,代码行数:28,代码来源:LiveCart.php

示例9: remove

 /**
  * Removes node from a category
  *
  * @role !category.remove
  */
 public function remove()
 {
     try {
         $categoryID = $this->request->get("id");
         $confirmed = $this->request->get("confirmed");
         $category = Category::getInstanceByID($categoryID, true);
         if ($category->getActiveProductCount()) {
             if (!$confirmed) {
                 return new JSONResponse(array('confirmMessage' => $this->translate('_confirm_remove_category_with_products'), 'url' => $this->application->getRouter()->createUrl(array('controller' => 'backend.category', 'action' => 'remove', 'id' => $categoryID, 'query' => array('confirmed' => 1)))), 'confirm');
             }
             // merge categoryID with child category IDs
             $categoryIDs = array_merge(Category::getRecordSet($category->getBranchFilter())->getRecordIDs(), array($categoryID));
             // all products under category that has additional categories
             $products = ActiveRecord::getRecordSet('Product', select(new AndChainCondition(array(IN(f('Product.categoryID'), $categoryIDs), new RegexpCond(f('Product.categoryIntervalCache'), '[0-9]+\\-[0-9]+\\,[0-9]+\\-[0-9]+')))));
             // move to aditional category, that is not in categoryIDs
             foreach ($products as $product) {
                 $chunks = explode(',', $product->categoryIntervalCache->get());
                 while ($pair = array_shift($chunks)) {
                     $sequence = explode('-', $pair);
                     if (!is_array($sequence) || count($sequence) != 2 || !is_numeric($sequence[0]) || !is_numeric($sequence[1])) {
                         continue;
                     }
                     $categorySet = Category::getRecordSet(select(new AndChainCondition(array(eq(f('Category.lft'), $sequence[0]), eq(f('Category.rgt'), $sequence[1])))));
                     if ($categorySet->size() != 1) {
                         continue;
                     }
                     $categoryToMove = $categorySet->shift();
                     if (in_array($categoryToMove->getID(), $categoryIDs)) {
                         // child category also will be removed. cant move here
                         continue;
                     }
                     $product->categoryID->set($categoryToMove);
                     $product->save();
                     break;
                     // product moved, don't care about other aditional categories.
                 }
             }
         }
         // and delete category.
         $category->delete();
         Category::recalculateProductsCount();
         return new JSONResponse(false, 'success', $this->translate('_category_was_successfully_removed'));
     } catch (Exception $e) {
         return new JSONResponse(false, 'failure', $this->translate('_could_not_remove_category'));
     }
 }
开发者ID:GregerA,项目名称:livecart,代码行数:51,代码来源:CategoryController.php

示例10: 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();
 }
开发者ID:saiber,项目名称:www,代码行数:17,代码来源:ObjectImage.php

示例11: status

 public function status()
 {
     $status = array();
     foreach (ActiveRecord::getRecordSet('ClonedStore', select()) as $store) {
         $f = new NetworkFetch('http://' . $store->domain->get() . '/storeSync/status');
         $f->fetch();
         $status[$store->getID()] = file_get_contents($f->getTmpFile()) == 'true';
     }
     $status['ready'] = count($status) == count(array_filter($status));
     return new JSONResponse($status);
 }
开发者ID:saiber,项目名称:www,代码行数:11,代码来源:CloneSyncController.php

示例12: getFirstChild

 public function getFirstChild($loadReferencedRecords = false)
 {
     if (!$this->isLoaded()) {
         $this->load();
     }
     $className = get_class($this);
     $filter = new ARSelectFilter();
     $filter->setCondition(new EqualsCond(new ARFieldHandle($className, self::PARENT_NODE_FIELD_NAME), $this->getField(self::PARENT_NODE_FIELD_NAME)->get()->getID()));
     $filter->setOrder(new ArFieldHandle($className, self::LEFT_NODE_FIELD_NAME));
     $filter->setLimit(1);
     $recordSet = ActiveRecord::getRecordSet($className, $filter, $loadReferencedRecords);
     foreach ($recordSet as $record) {
         return $record;
     }
     return null;
 }
开发者ID:saiber,项目名称:www,代码行数:16,代码来源:ActiveTreeNode.php

示例13: getLanguages

 private function getLanguages($active = 0)
 {
     $filter = new ARSelectFilter();
     $filter->setOrder(new ARFieldHandle("Language", "position"), ARSelectFilter::ORDER_ASC);
     if ($active > 0) {
         $filter->setCondition(new EqualsCond(new ARFieldHandle("Language", "isEnabled"), $active == 1 ? 1 : 0));
     }
     return ActiveRecord::getRecordSet("Language", $filter);
 }
开发者ID:GregerA,项目名称:livecart,代码行数:9,代码来源:LanguageController.php

示例14: importAdditionalCategories

 private function importAdditionalCategories(CsvImportProfile $profile, Product $product, $extraCategories)
 {
     $product->deleteRelatedRecordSet('ProductCategory');
     $instances = array();
     if (is_array($extraCategories)) {
         foreach ($extraCategories as $names) {
             $instances[] = $this->getCategoryByPath($profile, $names);
         }
     } else {
         if ($extraCategories instanceof Condition) {
             $instances = ActiveRecord::getRecordSet('Category', select($extraCategories));
         }
     }
     foreach ($instances as $cat) {
         ProductCategory::getNewInstance($product, $cat)->save();
     }
 }
开发者ID:saiber,项目名称:www,代码行数:17,代码来源:ProductImport.php


注:本文中的ActiveRecord::getRecordSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。