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


PHP ActiveRecord::getRecordSetArray方法代码示例

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


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

示例1: getNumber

 public function getNumber()
 {
     $config = ActiveRecordModel::getApplication()->getConfig();
     $startAt = $config->get('SequentialInvoiceNumber_START_AT');
     $prefix = $config->get('SequentialInvoiceNumber_PREFIX');
     $suffix = $config->get('SequentialInvoiceNumber_SUFFIX');
     // get last finalized order
     $last = array_pop(ActiveRecord::getRecordSetArray('CustomerOrder', $this->getSelectFilter()));
     $lastNumber = $last ? $last['invoiceNumber'] : $startAt;
     if (substr($lastNumber, 0, strlen($prefix)) == $prefix) {
         $lastNumber = substr($lastNumber, strlen($prefix));
     }
     if (substr($lastNumber, -1 * strlen($suffix)) == $suffix) {
         $lastNumber = substr($lastNumber, 0, -1 * strlen($suffix));
     }
     preg_match('/[0-9]+/', $lastNumber, $matches);
     $lastNumber = array_shift($matches);
     if ($lastNumber < $startAt) {
         $lastNumber = $startAt;
     }
     // avoid selecting the same order if the invoice number is already taken
     $this->getSelectFilter()->mergeCondition(neq('CustomerOrder.ID', $last['ID']));
     $lastNumber += max($config->get('SequentialInvoiceNumber_STEP'), 1);
     $lastNumber = str_pad($lastNumber, $config->get('SequentialInvoiceNumber_MIN_LENGTH'), '0', STR_PAD_LEFT);
     $lastNumber = $prefix . $lastNumber . $suffix;
     return $lastNumber;
 }
开发者ID:saiber,项目名称:livecart,代码行数:27,代码来源:SequentialInvoiceNumber.php

示例2: edit

 public function edit()
 {
     $newsletter = ActiveRecordModel::getInstanceById('NewsletterMessage', $this->request->get('id'), ActiveRecordModel::LOAD_DATA);
     $form = $this->getForm();
     $form->setData($newsletter->toArray());
     $form->set('users', 1);
     $form->set('subscribers', 1);
     $response = new ActionResponse('form', $form);
     $groupsArray = array_merge(ActiveRecord::getRecordSetArray('UserGroup', select()), array(array('ID' => null, 'name' => $this->translate('Customers'))));
     usort($groupsArray, array($this, 'sortGroups'));
     $response->set('groupsArray', $groupsArray);
     $newsletterArray = $newsletter->toArray();
     $text = strlen($newsletterArray['text']);
     $html = strlen($newsletterArray['html']);
     if ($text && $html) {
         $newsletterArray['format'] = self::FORMAT_HTML_TEXT;
     } else {
         if ($text) {
             $newsletterArray['format'] = self::FORMAT_TEXT;
         } else {
             if ($html) {
                 $newsletterArray['format'] = self::FORMAT_HTML;
             }
         }
     }
     $response->set('newsletter', $newsletterArray);
     $response->set('sentCount', $newsletter->getSentCount());
     $response->set('recipientCount', $this->getRecipientCount($form->getData()));
     return $response;
 }
开发者ID:saiber,项目名称:livecart,代码行数:30,代码来源:NewsletterController.php

示例3: insert

 protected function insert()
 {
     // get max position
     $f = new ARSelectFilter(new EqualsCond(new ARFieldHandle(__CLASS__, 'categoryID'), $this->getCategory()->getID()));
     $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();
 }
开发者ID:saiber,项目名称:www,代码行数:11,代码来源:ProductRatingType.php

示例4: getShippingMethods

 private function getShippingMethods()
 {
     ClassLoader::import('application.model.delivery.ShippingService');
     $methods = array();
     $f = select();
     $f->setOrder(f('DeliveryZone.ID'));
     $f->setOrder(f('ShippingService.position'));
     foreach (ActiveRecord::getRecordSetArray('ShippingService', $f, array('DeliveryZone')) as $service) {
         $methods[$service['ID']] = $service['name_lang'] . ' (' . $service['DeliveryZone']['name'] . ')';
     }
     return $methods;
 }
开发者ID:saiber,项目名称:www,代码行数:12,代码来源:DiscountController.php

示例5: 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

示例6: bestsellingProductsBlock

 public function bestsellingProductsBlock()
 {
     ClassLoader::import('application.model.product.ProductFilter');
     $cache = $this->application->getCache();
     $key = array('bestsellers', $this->getCategory()->getID() . '_' . $days);
     if (!$cache->get($key)) {
         $category = $this->getCategory();
         $filter = new ProductFilter($category, new ARSelectFilter());
         $filter->includeSubcategories();
         $filter->setEnabledOnly();
         $selectFilter = $filter->getSelectFilter();
         $selectFilter->setLimit($this->config->get('BESTSELLING_ITEMS_COUNT'));
         $selectFilter->setOrder(new ARExpressionHandle('cnt'), 'DESC');
         $q = new ARSelectQueryBuilder();
         $q->includeTable('Product');
         $q->joinTable('Category', 'Product', 'ID', 'categoryID');
         $q->addField('Product.ID');
         $q->addField(new ARExpressionHandle('(SELECT SUM(count) FROM OrderedItem LEFT JOIN CustomerOrder ON OrderedItem.customerOrderID=CustomerOrder.ID WHERE productID=Product.ID AND CustomerOrder.isPaid=1 AND CustomerOrder.dateCompleted > "' . ARSerializableDateTime::createFromTimeStamp(strtotime('-' . $this->config->get('BESTSELLING_ITEMS_DAYS') . ' days')) . '")'), null, 'cnt');
         $q->setFilter($selectFilter);
         $cache->set($key, ActiveRecord::getDataByQuery($q));
     }
     $products = $cache->get($key);
     if (!$products) {
         return;
     }
     $ids = array();
     foreach ($products as $id) {
         $ids[] = $id['ID'];
     }
     $products = ActiveRecord::getRecordSetArray('Product', select(IN('Product.ID', $ids)), array('DefaultImage' => 'ProductImage'));
     ProductPrice::loadPricesForRecordSetArray($products);
     if ($products) {
         return new BlockResponse('products', $products);
     }
 }
开发者ID:saiber,项目名称:www,代码行数:35,代码来源:FrontendController.php

示例7: insert

 protected function insert()
 {
     // get max position
     $f = new ARSelectFilter(self::getFilter($this->product->get())->getCondition());
     $f->setOrder(new ARFieldHandle(__CLASS__, "position"), 'DESC');
     $f->setLimit(1);
     $rec = ActiveRecord::getRecordSetArray(__CLASS__, $f);
     $position = is_array($rec) && count($rec) > 0 ? $rec[0]['position'] + 1 : 0;
     $this->position->set($position);
     return parent::insert();
 }
开发者ID:saiber,项目名称:www,代码行数:11,代码来源:ProductBundle.php

示例8: getFilterGroupArray

 /**
  * Returns a set of category filters
  *
  * @param bool $loadReferencedRecords
  * @return ARSet
  */
 public function getFilterGroupArray()
 {
     if (null === $this->filterGroupArrayCache) {
         ClassLoader::import('application.model.filter.FilterGroup');
         $filter = $this->getFilterGroupFilter();
         if (!$filter) {
             $this->filterGroupArrayCache = array();
         } else {
             $this->filterGroupArrayCache = ActiveRecord::getRecordSetArray('FilterGroup', $filter, array('SpecField'));
         }
     }
     return $this->filterGroupArrayCache;
 }
开发者ID:saiber,项目名称:www,代码行数:19,代码来源:Category.php

示例9: setLastPosition

 protected function setLastPosition($parentField = null, ARValueMapper $parent = null)
 {
     if ($parentField && !$parent) {
         $parent = $this->{$parentField};
     }
     $parentField .= 'ID';
     // get max position
     $cond = $parent ? new EqualsCond(new ARFieldHandle(get_class($this), $parentField), $parent->get()->getID()) : null;
     $f = new ARSelectFilter($cond);
     $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 : 0;
     // default new language state
     $this->position->set($position);
 }
开发者ID:saiber,项目名称:www,代码行数:16,代码来源:ActiveRecordModel.php

示例10: initLocales

 private function initLocales()
 {
     ClassLoader::import('library.locale.Locale');
     $filter = new ARSelectFilter();
     $filter->setOrder(new ARFieldHandle("Language", "position"), ARSelectFilter::ORDER_ASC);
     $filter->setCondition(new EqualsCond(new ARFieldHandle("Language", "isEnabled"), 1));
     if (count($this->limitToLocales) > 0) {
         $z = array();
         foreach ($this->limitToLocales as $localeCode) {
             $z[] = new EqualsCond(new ARFieldHandle("Language", "ID"), $localeCode);
         }
         $filter->mergeCondition(new OrChainCondition($z));
         // new INCond()
     }
     $languages = ActiveRecord::getRecordSetArray("Language", $filter);
     foreach ($languages as $language) {
         $locale = Locale::getInstance($language['ID']);
         $locale->translationManager()->setCacheFileDir(ClassLoader::getRealPath('storage.language'));
         foreach ($this->application->getConfigContainer()->getLanguageDirectories() as $dir) {
             $locale->translationManager()->setDefinitionFileDir($dir);
         }
         $locale->translationManager()->setDefinitionFileDir(ClassLoader::getRealPath('storage.language'));
         $locale->translationManager()->loadFile('backend/Settings');
         $this->locales[$language['ID']] = $locale;
     }
     $this->localeCodes = array_keys($this->locales);
 }
开发者ID:saiber,项目名称:livecart,代码行数:27,代码来源:SearchableConfigurationIndexing.php

示例11: loadData

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

示例12: getComparedProducts

 private function getComparedProducts()
 {
     $filter = Category::getRootNode()->getProductFilter(select(IN('Product.ID', $this->getComparedProductIDs())));
     $products = ActiveRecord::getRecordSetArray('Product', $filter, array('Category', 'ProductImage'));
     ProductSpecification::loadSpecificationForRecordSetArray($products, true);
     ProductPrice::loadPricesForRecordSetArray($products);
     return $products;
 }
开发者ID:saiber,项目名称:www,代码行数:8,代码来源:ProductCompare.php

示例13: updateRuleCache

 private function updateRuleCache()
 {
     $paths = array();
     $app = ActiveRecordModel::getApplication();
     foreach (array('condition', 'action') as $type) {
         $path = 'application.model.businessrule.' . $type;
         foreach ($app->getPluginClasses($path) as $class) {
             $paths[$class] = $app->getPluginClassPath($path, $class);
         }
     }
     $f = select(eq('DiscountCondition.isEnabled', true));
     $f->setOrder(f('DiscountCondition.position'));
     $conditions = ActiveRecord::getRecordSetArray('DiscountCondition', $f);
     $idMap = array();
     foreach ($conditions as &$condition) {
         $idMap[$condition['ID']] =& $condition;
     }
     // get condition records
     foreach (ActiveRecord::getRecordSetArray('DiscountConditionRecord', select(), array('Category')) as $record) {
         $idMap[$record['conditionID']]['records'][] = $record;
     }
     // get actions
     $f = select();
     $f->setOrder(f('DiscountAction.position'));
     foreach (ActiveRecord::getRecordSetArray('DiscountAction', $f) as $action) {
         if (!empty($action['actionConditionID'])) {
             $action['condition'] =& $idMap[$action['actionConditionID']];
         }
         $idMap[$action['conditionID']]['actions'][] = $action;
     }
     foreach ($conditions as &$condition) {
         if (!$condition['parentNodeID'] || !isset($idMap[$condition['parentNodeID']]) || !empty($condition['isActionCondition'])) {
             continue;
         }
         $idMap[$condition['parentNodeID']]['sub'][] =& $condition;
     }
     $rootCond = RuleCondition::createFromArray($idMap[DiscountCondition::ROOT_ID]);
     file_put_contents(self::getRuleFile(), '<?php $paths = ' . var_export($paths, true) . '; foreach ($paths as $path) { include_once($path); } return ' . var_export(serialize($rootCond->getConditions()), true) . '; ?>');
 }
开发者ID:saiber,项目名称:www,代码行数:39,代码来源:BusinessRuleController.php

示例14: insert

 protected function insert()
 {
     // get max position
     $f = new ARSelectFilter();
     $f->setOrder(new ARFieldHandle('StaticPage', 'position'), 'DESC');
     $f->setLimit(1);
     $rec = ActiveRecord::getRecordSetArray('StaticPage', $f);
     $position = is_array($rec) && count($rec) > 0 ? $rec[0]['position'] + 1 : 1;
     $this->position->set($position);
     return parent::insert();
 }
开发者ID:saiber,项目名称:livecart,代码行数:11,代码来源:StaticPage.php

示例15: insert

 protected function insert()
 {
     // get max position
     $f = self::getRelatedProductsSetFilter($this->product->get(), $this->type->get());
     $f->setLimit(1);
     $rec = ActiveRecord::getRecordSetArray('ProductRelationship', $f);
     $position = is_array($rec) && count($rec) > 0 ? $rec[0]['position'] + 1 : 0;
     $this->position->set($position);
     return parent::insert();
 }
开发者ID:saiber,项目名称:www,代码行数:10,代码来源:ProductRelationship.php


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