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


PHP Kwf_Model_Select::limit方法代码示例

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


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

示例1: _getSelect

 protected function _getSelect(ParamFetcher $paramFetcher, Request $request)
 {
     $select = new \Kwf_Model_Select();
     $select->limit($paramFetcher->get('limit'), $paramFetcher->get('start'));
     $queryValue = trim($request->get('query'));
     if ($queryValue) {
         $exprs = array();
         if (!$this->_queryColumns) {
             throw new \Kwf_Exception("_queryColumns are required to be set");
         }
         if ($this->_querySplit) {
             $queryValue = explode(' ', $queryValue);
         } else {
             $queryValue = array($queryValue);
         }
         foreach ($queryValue as $q) {
             $e = array();
             foreach ($this->_queryColumns as $c) {
                 $e[] = new \Kwf_Model_Select_Expr_Like($c, '%' . $q . '%');
             }
             if (count($e) > 1) {
                 $exprs[] = new \Kwf_Model_Select_Expr_Or($e);
             } else {
                 $exprs[] = $e[0];
             }
         }
         if (count($exprs) > 1) {
             $select->where(new \Kwf_Model_Select_Expr_And($exprs));
         } else {
             $select->where($exprs[0]);
         }
     }
     return $select;
 }
开发者ID:koala-framework,项目名称:koala-framework,代码行数:34,代码来源:FOSRestModelController.php

示例2: buildSelect

 public function buildSelect(Request $request, array $options = array())
 {
     $select = new \Kwf_Model_Select();
     if ($request->get('limit')) {
         $select->limit($request->get('limit'), $request->get('start'));
     } else {
         $select->limit(25, $request->get('start'));
     }
     $queryValue = trim($request->get('query'));
     if ($queryValue) {
         $queryColumns = null;
         if (isset($options['queryColumns'])) {
             $queryColumns = $options['queryColumns'];
         }
         $exprs = array();
         if (!$queryColumns) {
             throw new \Kwf_Exception("queryColumns are required to be set");
         }
         if (isset($options['querySplit']) && $options['querySplit']) {
             $queryValue = explode(' ', $queryValue);
         } else {
             $queryValue = array($queryValue);
         }
         foreach ($queryValue as $q) {
             $e = array();
             foreach ($queryColumns as $c) {
                 $e[] = new \Kwf_Model_Select_Expr_Like($c, '%' . $q . '%');
             }
             if (count($e) > 1) {
                 $exprs[] = new \Kwf_Model_Select_Expr_Or($e);
             } else {
                 $exprs[] = $e[0];
             }
         }
         if (count($exprs) > 1) {
             $select->where(new \Kwf_Model_Select_Expr_And($exprs));
         } else {
             $select->where($exprs[0]);
         }
     }
     $restColumns = $this->model->getSerializationColumns(array('rest_read', 'rest'));
     $exprColumns = $this->model->getExprColumns();
     foreach (array_intersect(array_keys($restColumns), $exprColumns) as $i) {
         $select->expr($i);
     }
     return $select;
 }
开发者ID:koala-framework,项目名称:koala-framework,代码行数:47,代码来源:Handler.php

示例3: initialSync

 public function initialSync($processInCli = true)
 {
     $stepSize = 100;
     $format = self::_optimalImportExportFormat($this->getProxyModel(), $this->getSourceModel());
     $count = $this->_sourceModel->countRows();
     $progress = null;
     if (PHP_SAPI == 'cli' && $processInCli) {
         $c = new Zend_ProgressBar_Adapter_Console();
         $c->setElements(array(Zend_ProgressBar_Adapter_Console::ELEMENT_PERCENT, Zend_ProgressBar_Adapter_Console::ELEMENT_BAR, Zend_ProgressBar_Adapter_Console::ELEMENT_ETA, Zend_ProgressBar_Adapter_Console::ELEMENT_TEXT));
         $progress = new Zend_ProgressBar($c, 0, $count);
     }
     $startTime = microtime(true);
     $this->getProxyModel()->deleteRows(array());
     //alles löschen
     for ($offset = 0; $offset < $count; $offset += $stepSize) {
         $s = new Kwf_Model_Select();
         $s->limit($stepSize, $offset);
         /*
         $data = $this->_sourceModel->export($format, $s);
         $this->getProxyModel()->import($format, $data);
         */
         //warning: slow code ahead
         foreach ($this->_sourceModel->getRows($s) as $row) {
             $data = $row->toArray();
             $newRow = $this->createRow($data);
             foreach ($this->getDependentModels() as $rule => $depModel) {
                 if ($depModel instanceof Kwf_Model_RowsSubModel_MirrorCacheSimple) {
                     //dieser code könne vielleicht im Kwf_Model_RowsSubModel_MirrorCacheSimple liegen
                     $m = $depModel->getSourceModel();
                     $ref = $m->getReferenceByModelClass(get_class($this), null);
                     $select = new Kwf_Model_Select();
                     $select->whereEquals($ref['column'], $row->{$this->getPrimaryKey()});
                     $childRows = $m->getRows($select);
                     foreach ($childRows as $childRow) {
                         $newCRow = $newRow->createChildRow($rule, $childRow->toArray());
                     }
                 }
             }
             $newRow->save();
         }
         unset($row);
         unset($newRow);
         unset($newCRow);
         unset($childRows);
         unset($childRow);
         foreach (self::getInstances() as $m) {
             $m->clearRows();
         }
         //echo round(memory_get_usage()/(1024*1024), 3)."MB\n";
         if ($progress) {
             $text = round(($offset + $stepSize) / (microtime(true) - $startTime)) . ' rows/sec';
             $progress->next($stepSize, $text);
         }
     }
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:55,代码来源:MirrorCacheSimple.php

示例4: testSelect

 public function testSelect()
 {
     $select = new Kwf_Model_Select();
     $select->where('foo = ?', 1);
     $this->assertEquals($select->getPart(Kwf_Model_Select::WHERE), array(array('foo = ?', 1, null)));
     $select->where('bar = ?', 1);
     $this->assertEquals($select->getPart(Kwf_Model_Select::WHERE), array(array('foo = ?', 1, null), array('bar = ?', 1, null)));
     $select->whereEquals('foo', 1);
     $this->assertEquals($select->getPart(Kwf_Model_Select::WHERE_EQUALS), array('foo' => 1));
     $select->whereEquals('foo', 'bar');
     $this->assertEquals($select->getPart(Kwf_Model_Select::WHERE_EQUALS), array('foo' => 'bar'));
     $select->whereEquals('foo2', 'bar2');
     $this->assertEquals($select->getPart(Kwf_Model_Select::WHERE_EQUALS), array('foo' => 'bar', 'foo2' => 'bar2'));
     $select->order('foo');
     $this->assertEquals($select->getPart(Kwf_Model_Select::ORDER), array(array('field' => 'foo', 'direction' => 'ASC')));
     $select->order('foo2', 'DESC');
     $this->assertEquals($select->getPart(Kwf_Model_Select::ORDER), array(array('field' => 'foo', 'direction' => 'ASC'), array('field' => 'foo2', 'direction' => 'DESC')));
     $select->limit(10);
     $this->assertEquals($select->getPart(Kwf_Model_Select::LIMIT_COUNT), 10);
     $this->assertEquals($select->getPart(Kwf_Model_Select::LIMIT_OFFSET), null);
     $select->limit(20);
     $this->assertEquals($select->getPart(Kwf_Model_Select::LIMIT_COUNT), 20);
     $select->limit(25, 10);
     $this->assertEquals($select->getPart(Kwf_Model_Select::LIMIT_COUNT), 25);
     $this->assertEquals($select->getPart(Kwf_Model_Select::LIMIT_OFFSET), 10);
     $this->assertEquals(count($select->getParts()), 5);
     $select = new Kwf_Model_Select(array('id' => 1));
     $this->assertEquals($select->getPart(Kwf_Model_Select::WHERE_ID), 1);
     $select->whereId(10);
     $this->assertEquals($select->getPart(Kwf_Model_Select::WHERE_ID), 10);
     $select->whereId(11);
     $this->assertEquals($select->getPart(Kwf_Model_Select::WHERE_ID), 11);
     $select = new Kwf_Model_Select();
     $select->order(Kwf_Model_Select::ORDER_RAND);
     $this->assertEquals($select->getPart(Kwf_Model_Select::ORDER), array(array('field' => Kwf_Model_Select::ORDER_RAND, 'direction' => 'ASC')));
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:36,代码来源:SelectTest.php

示例5: jsonPasteAction

 public function jsonPasteAction()
 {
     $session = new Kwf_Session_Namespace('PagesController:copy');
     $id = $session->id;
     if (!$id || !Kwf_Component_Data_Root::getInstance()->getComponentByDbId($id, array('ignoreVisible' => true))) {
         throw new Kwf_Exception_Client(trlKwf('Clipboard is empty'));
     }
     $source = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($id, array('ignoreVisible' => true));
     $target = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($this->_getParam('id'), array('ignoreVisible' => true));
     $user = Zend_Registry::get('userModel')->getAuthedUser();
     $acl = Kwf_Registry::get('acl')->getComponentAcl();
     if (!$acl->isAllowed($user, $source) || !$acl->isAllowed($user, $target)) {
         throw new Kwf_Exception_AccessDenied();
     }
     $progressBar = new Zend_ProgressBar(new Kwf_Util_ProgressBar_Adapter_Cache($this->_getParam('progressNum')), 0, Kwf_Util_Component::getDuplicateProgressSteps($source));
     Kwf_Util_MemoryLimit::set(256);
     Kwf_Events_ModelObserver::getInstance()->disable();
     //This would be slow as hell. But luckily we can be sure that for the new (duplicated) components there will be no view cache to clear.
     $newPage = Kwf_Util_Component::duplicate($source, $target, $progressBar);
     Kwf_Util_Component::afterDuplicate($source, $newPage);
     Kwf_Events_ModelObserver::getInstance()->enable();
     $progressBar->finish();
     $s = new Kwf_Model_Select();
     $s->whereEquals('parent_id', $newPage->row->parent_id);
     $s->order('pos', 'DESC');
     $s->limit(1);
     $lastRow = $newPage->generator->getModel()->getRow($s);
     $row = $newPage->generator->getModel()->getRow($newPage->row->id);
     $row->pos = $lastRow ? $lastRow->pos + 1 : 1;
     $row->visible = false;
     $row->save();
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:32,代码来源:PagesController.php

示例6: testGetIdsOrderLimit

 public function testGetIdsOrderLimit()
 {
     $s = new Kwf_Model_Select();
     $s->limit(2);
     $s->order('foo');
     $ids = $this->_m->getIds($s);
     $this->assertEquals(2, count($ids));
     $this->assertEquals('1m2', $ids[0]);
     $this->assertEquals('2m2', $ids[1]);
     $s = new Kwf_Model_Select();
     $s->limit(2, 2);
     $s->order('foo');
     $ids = $this->_m->getIds($s);
     $this->assertEquals('1m1', $ids[0]);
     $this->assertEquals('1m3', $ids[1]);
     $s = new Kwf_Model_Select();
     $s->limit(2, 4);
     $s->order('foo');
     $ids = $this->_m->getIds($s);
     $this->assertEquals('2m1', $ids[0]);
     $this->assertEquals('2m3', $ids[1]);
 }
开发者ID:nsams,项目名称:koala-framework,代码行数:22,代码来源:Test.php

示例7: select

 public function select($where = array(), $order = null, $limit = null, $start = null)
 {
     if (!is_array($where)) {
         $ret = new Kwf_Model_Select();
         if ($where) {
             $ret->whereEquals($this->getPrimaryKey(), $where);
         }
     } else {
         $ret = new Kwf_Model_Select($where);
     }
     if ($order) {
         $ret->order($order);
     }
     if ($limit || $start) {
         $ret->limit($limit, $start);
     }
     return $ret;
 }
开发者ID:nsams,项目名称:koala-framework,代码行数:18,代码来源:Db.php


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