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


PHP ARSelectFilter::setLimit方法代码示例

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


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

示例1: getActiveProductManufacturers

 /**
  *
  * @return array('manufacturers'=> array of manufacturers, 'counts'=> manufacturer product count, 'count'=> count of manufacturers)
  */
 public static function getActiveProductManufacturers($context)
 {
     $context = $context + array('startingWith' => null, 'currentPage' => 1);
     extract($context);
     // creates $startingWith and $currentPage
     $config = ActiveRecordModel::getApplication()->getConfig();
     $listStyle = $config->get('MANUFACTURER_PAGE_LIST_STYLE');
     $perPage = $config->get('MANUFACTURER_PAGE_PER_PAGE');
     // get filter to select manufacturers of active products only
     $f = new ARSelectFilter();
     $ids = $counts = $letters = array();
     $sql = !self::getApplication()->getConfig()->get('MANUFACTURER_PAGE_DISPLAY_ACTIVE') ? 'SELECT DISTINCT(ID) as manufacturerID, 1 AS cnt FROM Manufacturer ' . $f->createString() . ' GROUP BY manufacturerID' : 'SELECT DISTINCT(manufacturerID), COUNT(*) AS cnt FROM Product ' . $f->createString() . ' GROUP BY manufacturerID';
     foreach (ActiveRecordModel::getDataBySQL($sql) as $row) {
         $ids[] = $row['manufacturerID'];
         $counts[$row['manufacturerID']] = $row['cnt'];
     }
     $f = new ARSelectFilter(new InCond(new ARFieldHandle('Manufacturer', 'ID'), $ids));
     $f->addField('UPPER(LEFT(TRIM(Manufacturer.name),1))', '', 'FirstLetter');
     $f->mergeCondition(new NotEqualsCond(new ARFieldHandle('Manufacturer', 'name'), ''));
     if ($startingWith) {
         $f->mergeCondition(new LikeCond(new ARFieldHandle('Manufacturer', 'name'), $startingWith . '%'));
     }
     $f->setOrder(new ARFieldHandle('Manufacturer', 'name'));
     if ($perPage > 0) {
         $offsetStart = ($currentPage - 1) * $perPage + 1;
         $offsetEnd = $currentPage * $perPage;
         $f->setLimit($perPage, $offsetStart - 1);
     }
     $manufacturers = ActiveRecordModel::getRecordSetArray(__CLASS__, $f);
     foreach ($manufacturers as $item) {
         $letters[$item['FirstLetter']] = $item['FirstLetter'];
     }
     return array('manufacturers' => $manufacturers, 'counts' => $counts, 'count' => ActiveRecordModel::getRecordCount(__CLASS__, $f));
 }
开发者ID:saiber,项目名称:livecart,代码行数:38,代码来源:Manufacturer.php

示例2: reorder

 /**
  * Reorder pages
  *
  * @role sort
  */
 public function reorder()
 {
     $inst = StaticPage::getInstanceById($this->request->get('id'), StaticPage::LOAD_DATA);
     $f = new ARSelectFilter();
     $handle = new ARFieldHandle('StaticPage', 'position');
     if ('down' == $this->request->get('order')) {
         $f->setCondition(new MoreThanCond($handle, $inst->position->get()));
         $f->setOrder($handle, 'ASC');
     } else {
         $f->setCondition(new LessThanCond($handle, $inst->position->get()));
         $f->setOrder($handle, 'DESC');
     }
     $f->setLimit(1);
     $s = ActiveRecordModel::getRecordSet('StaticPage', $f);
     if ($s->size()) {
         $pos = $inst->position->get();
         $replace = $s->get(0);
         $inst->position->set($replace->position->get());
         $replace->position->set($pos);
         $inst->save();
         $replace->save();
         return new JSONResponse(array('id' => $inst->getID(), 'order' => $this->request->get('order')), 'success');
     } else {
         return new JSONResponse(false, 'failure', $this->translate('_could_not_reorder_pages'));
     }
 }
开发者ID:saiber,项目名称:www,代码行数:31,代码来源:StaticPageController.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: getInstanceByName

 public static function getInstanceByName($name)
 {
     $filter = new ARSelectFilter();
     $filter->setCondition(new EqualsCond(new ARFieldHandle('Manufacturer', 'name'), $name));
     $filter->setLimit(1);
     $set = ActiveRecordModel::getRecordSet('Manufacturer', $filter);
     if ($set->size() > 0) {
         return $set->get(0);
     } else {
         return self::getNewInstance($name);
     }
 }
开发者ID:saiber,项目名称:www,代码行数:12,代码来源:Manufacturer.php

示例5: getOrder

 /**
  * Get CustomerOrder instance from session
  *
  * @return CustomerOrder
  */
 public static function getOrder()
 {
     if (self::$instance) {
         return self::$instance;
     }
     $session = new Session();
     $id = $session->get('CustomerOrder');
     if ($id) {
         try {
             $instance = CustomerOrder::getInstanceById($id, true);
             if (!$instance->getOrderedItems()) {
                 $instance->loadItems();
             }
             $instance->isSyncedToSession = true;
         } catch (ARNotFoundException $e) {
             unset($instance);
         }
     }
     if (!isset($instance)) {
         $userId = SessionUser::getUser()->getID();
         // get the last unfinalized order by this user
         if ($userId > 0) {
             $f = new ARSelectFilter(new EqualsCond(new ARFieldHandle('CustomerOrder', 'userID'), $userId));
             $f->mergeCondition(new NotEqualsCond(new ARFieldHandle('CustomerOrder', 'isFinalized'), true));
             $f->setOrder(new ARFieldHandle('CustomerOrder', 'ID'), 'DESC');
             $f->setLimit(1);
             $orders = ActiveRecordModel::getRecordSet('CustomerOrder', $f);
             if ($orders->size()) {
                 $instance = $orders->get(0);
             }
         }
     }
     if (!isset($instance)) {
         $instance = CustomerOrder::getNewInstance(User::getNewInstance(0));
         $instance->user->set(NULL);
     }
     if (!$instance->user->get() && SessionUser::getUser()->getID() > 0) {
         $instance->setUser(SessionUser::getUser());
         $instance->save();
     }
     if ($instance->isFinalized->get()) {
         $session->unsetValue('CustomerOrder');
         return self::getOrder();
     }
     // fixes issue when trying to add OrderedItem to unsaved(without ID) CustomerOrder.
     // ~ but i don't know if returning unsaved CustomerOrder is expected behaviour.
     if ($instance->isExistingRecord() == false) {
         $instance->save(true);
     }
     self::setOrder($instance);
     return $instance;
 }
开发者ID:saiber,项目名称:livecart,代码行数:57,代码来源:SessionOrder.php

示例6: index

 public function index()
 {
     ClassLoader::import('application.controller.CategoryController');
     $this->request->set('id', Category::ROOT_ID);
     $this->request->set('cathandle', '-');
     $response = parent::index();
     // load site news
     $f = new ARSelectFilter(new EqualsCond(new ARFieldHandle('NewsPost', 'isEnabled'), true));
     $f->setOrder(new ARFieldHandle('NewsPost', 'position'), 'DESC');
     $f->setLimit($this->config->get('NUM_NEWS_INDEX') + 1);
     $news = ActiveRecordModel::getRecordSetArray('NewsPost', $f);
     $response->set('news', $news);
     $response->set('isNewsArchive', count($news) > $this->config->get('NUM_NEWS_INDEX'));
     return $response;
 }
开发者ID:saiber,项目名称:www,代码行数:15,代码来源:IndexController.php

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

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

示例9: autoComplete

 public function autoComplete()
 {
     $f = new ARSelectFilter();
     $f->setLimit(20);
     $resp = array();
     $field = $this->request->get('field');
     if ('specField_' == substr($field, 0, 10)) {
         list($foo, $id) = explode('_', $field);
         $handle = new ARFieldHandle('EavStringValue', 'value');
         $locale = $this->locale->getLocaleCode();
         $searchHandle = MultilingualObject::getLangSearchHandle($handle, $locale);
         $f->setCondition(new EqualsCond(new ARFieldHandle('EavStringValue', 'fieldID'), $id));
         $f->mergeCondition(new LikeCond($handle, '%:"' . $this->request->get($field) . '%'));
         $f->mergeCondition(new LikeCond($searchHandle, $this->request->get($field) . '%'));
         $f->setOrder($searchHandle, 'ASC');
         $results = ActiveRecordModel::getRecordSet('EavStringValue', $f);
         foreach ($results as $value) {
             $resp[$value->getValueByLang('value', $locale, MultilingualObject::NO_DEFAULT_VALUE)] = true;
         }
         $resp = array_keys($resp);
     }
     return new AutoCompleteResponse($resp);
 }
开发者ID:saiber,项目名称:livecart,代码行数:23,代码来源:EavFieldValueController.php

示例10: isPurchaseRequiredToRate

 private function isPurchaseRequiredToRate(Product $product)
 {
     if ($this->config->get('REQUIRE_PURCHASE_TO_RATE')) {
         if ($this->user->isAnonymous()) {
             return true;
         }
         if (is_null($this->isPurchaseRequiredToRate)) {
             ClassLoader::import('application.model.order.CustomerOrder');
             $f = new ARSelectFilter(new EqualsCond(new ARFieldHandle('CustomerOrder', 'userID'), $this->user->getID()));
             $f->mergeCondition(new EqualsCond(new ARFieldHandle('OrderedItem', 'productID'), $product->getID()));
             $f->mergeCondition(new EqualsCond(new ARFieldHandle('CustomerOrder', 'isFinalized'), 1));
             $f->setLimit(1);
             $this->isPurchaseRequiredToRate = ActiveRecordModel::getRecordCount('OrderedItem', $f, array('CustomerOrder')) < 1;
         }
         return $this->isPurchaseRequiredToRate;
     }
 }
开发者ID:saiber,项目名称:www,代码行数:17,代码来源:ProductController.php

示例11: autoComplete

 public function autoComplete()
 {
     $f = new ARSelectFilter();
     $f->setLimit(20);
     $resp = array();
     $field = $this->request->get('field');
     if (in_array($field, array('sku', 'URL', 'keywords'))) {
         $c = new LikeCond(new ARFieldHandle('Product', $field), $this->request->get($field) . '%');
         $f->setCondition($c);
         $f->setOrder(new ARFieldHandle('Product', $field), 'ASC');
         $query = new ARSelectQueryBuilder();
         $query->setFilter($f);
         $query->includeTable('Product');
         $query->addField('DISTINCT(Product.' . $field . ')');
         $results = ActiveRecordModel::getDataBySQL($query->createString());
         foreach ($results as $value) {
             $resp[] = $value[$field];
         }
     } else {
         if ('name' == $field) {
             $c = new LikeCond(new ARFieldHandle('Product', $field), '%:"' . $this->request->get($field) . '%');
             $f->setCondition($c);
             $locale = $this->locale->getLocaleCode();
             $langCond = new LikeCond(Product::getLangSearchHandle(new ARFieldHandle('Product', 'name'), $locale), $this->request->get($field) . '%');
             $c->addAND($langCond);
             $f->setOrder(Product::getLangSearchHandle(new ARFieldHandle('Product', 'name'), $locale), 'ASC');
             $results = ActiveRecordModel::getRecordSet('Product', $f);
             foreach ($results as $value) {
                 $resp[$value->getValueByLang('name', $locale, Product::NO_DEFAULT_VALUE)] = true;
             }
             $resp = array_keys($resp);
         } else {
             if ('specField_' == substr($field, 0, 10)) {
                 list($foo, $id) = explode('_', $field);
                 $handle = new ARFieldHandle('SpecificationStringValue', 'value');
                 $locale = $this->locale->getLocaleCode();
                 $searchHandle = MultiLingualObject::getLangSearchHandle($handle, $locale);
                 $f->setCondition(new EqualsCond(new ARFieldHandle('SpecificationStringValue', 'specFieldID'), $id));
                 $f->mergeCondition(new LikeCond($handle, '%:"' . $this->request->get($field) . '%'));
                 $f->mergeCondition(new LikeCond($searchHandle, $this->request->get($field) . '%'));
                 $f->setOrder($searchHandle, 'ASC');
                 $results = ActiveRecordModel::getRecordSet('SpecificationStringValue', $f);
                 foreach ($results as $value) {
                     $resp[$value->getValueByLang('value', $locale, Product::NO_DEFAULT_VALUE)] = true;
                 }
                 $resp = array_keys($resp);
             }
         }
     }
     return new AutoCompleteResponse($resp);
 }
开发者ID:saiber,项目名称:www,代码行数:51,代码来源:ProductController.php

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

示例13: mergeOrder

 private function mergeOrder()
 {
     // load the last un-finalized order by this user
     $f = new ARSelectFilter(new EqualsCond(new ARFieldHandle('CustomerOrder', 'userID'), $this->user->getID()));
     $f->mergeCondition(new NotEqualsCond(new ARFieldHandle('CustomerOrder', 'isFinalized'), true));
     $f->setOrder(new ARFieldHandle('CustomerOrder', 'dateCreated'), 'DESC');
     $f->setLimit(1);
     $s = ActiveRecordModel::getRecordSet('CustomerOrder', $f, ActiveRecordModel::LOAD_REFERENCES);
     if (!$this->order->user->get() || $this->order->user->get()->getID() == $this->user->getID()) {
         if ($s->size()) {
             $order = $s->get(0);
             if ($this->order->getID() != $order->getID()) {
                 $sessionOrder = SessionOrder::getOrder();
                 $order->loadItems();
                 $order->merge($sessionOrder);
                 $order->save();
                 SessionOrder::setOrder($order);
                 $this->order->delete();
             }
         } else {
             if ($this->order->getID()) {
                 $this->order->setUser($this->user);
                 SessionOrder::save($this->order);
             }
         }
     }
 }
开发者ID:GregerA,项目名称:livecart,代码行数:27,代码来源:UserController.php

示例14: getPage

 private function getPage($class, $page, ARSelectFilter $f, $fields)
 {
     $f->setLimit(self::MAX_URLS, $page * self::MAX_URLS);
     $query = new ARSelectQueryBuilder();
     $query->setFilter($f);
     $query->includeTable($class);
     foreach ($fields as $field) {
         $query->addField($field);
     }
     return ActiveRecord::fetchDataFromDB($query);
 }
开发者ID:saiber,项目名称:www,代码行数:11,代码来源:SitemapController.php

示例15: getStateByIDAndCountry

 /**
  * Provides an additional verification that state belongs to the particular country
  *
  * @return ActiveRecord
  */
 public static function getStateByIDAndCountry($stateID, $countryID)
 {
     $f = new ARSelectFilter();
     $f->setCondition(new EqualsCond(new ARFieldHandle('State', 'ID'), $stateID));
     $f->mergeCondition(new EqualsCond(new ARFieldHandle('State', 'countryID'), $countryID));
     $f->setLimit(1);
     $states = ActiveRecordModel::getRecordSet('State', $f);
     if ($states) {
         return $states->get(0);
     } else {
         return null;
     }
 }
开发者ID:saiber,项目名称:livecart,代码行数:18,代码来源:State.php


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