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


PHP Doctrine_Query::limit方法代码示例

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


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

示例1: testQuerySetLimitToZero

 public function testQuerySetLimitToZero()
 {
     $q = new Doctrine_Query();
     $q->from('User u');
     $q->limit(20);
     $q->limit(0);
     $this->assertEqual($q->getSqlQuery(), 'SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id FROM entity e WHERE (e.type = 0)');
 }
开发者ID:dennybrandes,项目名称:doctrine1,代码行数:8,代码来源:RemoveQueryPartTestCase.php

示例2: getItems

 /**
  * Get items
  *
  * @param int $offset
  * @param int $itemsPerPage
  * @return Doctrine_Collection
  */
 public function getItems($offset, $itemsPerPage)
 {
     if ($itemsPerPage !== null) {
         $this->_query->limit($itemsPerPage);
     }
     if ($offset !== null) {
         $this->_query->offset($offset);
     }
     return $this->_query->execute();
 }
开发者ID:lciolecki,项目名称:zf-doctrine,代码行数:17,代码来源:DoctrineQuery.php

示例3: getItems

 /**
  * Returns an collection of items for a page.
  *
  * @param  integer $offset Page offset
  * @param  integer $itemCountPerPage Number of items per page
  * @return array
  */
 public function getItems($offset, $itemCountPerPage)
 {
     $data = $this->_query->limit($itemCountPerPage)->offset($offset)->execute();
     if ($data instanceof Doctrine_Collection) {
         return $data->getData();
     } elseif (is_array($data)) {
         return $data;
     } else {
         $message = sprintf('Unexpected datatype for getItems(): %s', Robo47_Core::getType($data));
         throw new Robo47_Paginator_Adapter_Exception($message);
     }
 }
开发者ID:robo47,项目名称:robo47-components,代码行数:19,代码来源:DoctrineQuery.php

示例4: getSetting

 /**
  * getSetting
  * pulls the sfSetting object for a given setting
  * 
  * @param string $setting 
  * @static
  * @access public
  * @return object sfSetting
  */
 static function getSetting($setting)
 {
     if (!is_string($setting) || empty($setting)) {
         return 0;
     }
     // If all the settings have been requested, there's no need to check for
     // individuals. This avoids additional queries later on.
     if (sfContext::getInstance()->getRequest()->hasAttribute('AllsfSettings')) {
         $settings = sfContext::getInstance()->getRequest()->getAttribute('AllsfSettings');
     } else {
         $settings = sfContext::getInstance()->getRequest()->getAttribute('sfSettings');
     }
     if (isset($settings[$setting])) {
         $obj = $settings[$setting];
         return $obj;
     } else {
         // Setting was not pre-loaded via ->load() but we'll be nice and retrieve
         // the setting anyhow:
         $query = new Doctrine_Query();
         $query->addSelect("s.*");
         $query->addFrom("sfSetting s");
         $query->addWhere("s.name = :name", array(":name" => $setting));
         if ($obj = $query->limit(1)->execute()->getFirst()) {
             // Store this setting in memory for later retrieval to avoid a second
             // query for the same setting:
             $settings[$obj->getName()] = $obj;
             sfContext::getInstance()->getRequest()->setAttribute('sfSettings', $settings);
             // return it:
             return $obj;
         } else {
             return 0;
         }
     }
 }
开发者ID:bshaffer,项目名称:Symplist,代码行数:43,代码来源:BasesfSettings.class.php

示例5: getItems

 /**
  * Implementation of method from Zend_Paginator_Adapter_Interface.
  *
  * @param integer $offset
  * @param integer $itemsPerPage
  * @return array[numeric|whatever]=>array|Doctrine_Record
  */
 public function getItems($offset, $itemsPerPage)
 {
     $this->_query->limit($itemsPerPage);
     $this->_query->offset($offset);
     $result = $this->_query->execute(array(), $this->_hydrationMode);
     return $result;
 }
开发者ID:Neozeratul,项目名称:Intermodels,代码行数:14,代码来源:Adapter.php

示例6: addUpcoming

 public function addUpcoming(Doctrine_Query $q, $limit = null)
 {
     $q->orderBy('start_date');
     $q->addWhere('DATE(start_date) >= DATE(NOW())');
     if (!is_null($limit)) {
         $q->limit($limit);
     }
 }
开发者ID:quafzi,项目名称:timpany-prototype,代码行数:8,代码来源:PluginaEventTable.class.php

示例7: testGetLimitSubqueryWithOrderByOnAggregateValuesAndColumns

 public function testGetLimitSubqueryWithOrderByOnAggregateValuesAndColumns()
 {
     $q = new Doctrine_Query();
     $q->select('u.name, COUNT(DISTINCT a.id) num_albums');
     $q->from('User u, u.Album a');
     $q->orderby('num_albums, u.name');
     $q->groupby('u.id');
     $q->limit(5);
     $q->execute();
     $this->assertEqual($this->dbh->pop(), 'SELECT e.id AS e__id, e.name AS e__name, COUNT(DISTINCT a.id) AS a__0 FROM entity e LEFT JOIN album a ON e.id = a.user_id WHERE e.id IN (SELECT doctrine_subquery_alias.id FROM (SELECT DISTINCT e2.id, COUNT(DISTINCT a2.id) AS a2__0 FROM entity e2 LEFT JOIN album a2 ON e2.id = a2.user_id WHERE (e2.type = 0) GROUP BY e2.id ORDER BY a2__0, e2.name LIMIT 5) AS doctrine_subquery_alias) AND (e.type = 0) GROUP BY e.id ORDER BY a__0, e.name');
 }
开发者ID:ninjapenguin,项目名称:kohana-Doctrine-module,代码行数:11,代码来源:PgsqlSubqueryTestCase.php

示例8: testGetLimitSubqueryWithHavingOnAggregateValuesIncorrectAlias

 public function testGetLimitSubqueryWithHavingOnAggregateValuesIncorrectAlias()
 {
     $q = new Doctrine_Query();
     $q->select('u.name, COUNT(a.id) num_albums');
     $q->from('User u, u.Album a');
     $q->orderby('num_albums DESC');
     $q->having('num_albums > 0');
     $q->groupby('u.id');
     $q->limit(5);
     $q->execute();
     $this->dbh->pop();
     $this->assertEqual($this->dbh->pop(), 'SELECT DISTINCT e2.id, COUNT(a2.id) AS a2__0 FROM entity e2 LEFT JOIN album a2 ON e2.id = a2.user_id WHERE (e2.type = 0) GROUP BY e2.id HAVING a2__0 > 0 ORDER BY a2__0 DESC LIMIT 5');
 }
开发者ID:swk,项目名称:bluebox,代码行数:13,代码来源:MysqlSubqueryHavingTestCase.php

示例9: testSubqueryExtractionUsesWrongAliases

 public function testSubqueryExtractionUsesWrongAliases()
 {
     $q = new Doctrine_Query();
     $q->from('RelX x');
     $q->leftJoin('x.y xy');
     $q->where('x.created_at IN (SELECT MAX(x2.created_at) latestInCategory FROM RelX x2 WHERE x.category = x2.category)');
     $q->limit(5);
     //echo $sql = $q->getSqlQuery();
     //	echo $sql;
     $xs = $q->execute();
     // Doctrine_Ticket_1254_TestCase : method testSubqueryExtractionUsesWrongAliases failed on line 76
     // This fails sometimes at
     $this->assertEqual(2, count($xs));
 }
开发者ID:dennybrandes,项目名称:doctrine1,代码行数:14,代码来源:1254TestCase.php

示例10: testSubqueryExtractionUsesWrongAliases

    public function testSubqueryExtractionUsesWrongAliases()
    {
        $q = new Doctrine_Query();
        $q->from('RelX x');
    	$q->leftJoin('x.y xy');
    	$q->where('x.created_at IN (SELECT MAX(x2.created_at) latestInCategory FROM RelX x2 WHERE x.category = x2.category)');
    	$q->limit(5);

        //echo $sql = $q->getSql();
        //	echo $sql;

        $xs = $q->execute();
        
        $this->assertEqual(3, count($xs));
        
    }
开发者ID:prismhdd,项目名称:victorioussecret,代码行数:16,代码来源:1254TestCase.php

示例11: testGetLimitSubqueryOrderBy2

 public function testGetLimitSubqueryOrderBy2()
 {
     $q = new Doctrine_Query();
     $q->select('u.name, COUNT(DISTINCT a.id) num_albums');
     $q->from('User u, u.Album a');
     $q->orderby('num_albums');
     $q->groupby('u.id');
     try {
         // this causes getLimitSubquery() to be used, and it fails
         $q->limit(5);
         $users = $q->execute();
         $count = $users->count();
     } catch (Doctrine_Exception $e) {
         $this->fail();
     }
     $this->assertEqual($q->getSql(), 'SELECT e.id AS e__id, e.name AS e__name, COUNT(DISTINCT a.id) AS a__0 FROM entity e LEFT JOIN album a ON e.id = a.user_id WHERE e.id IN (SELECT DISTINCT e2.id FROM entity e2 LEFT JOIN album a2 ON e2.id = a2.user_id WHERE (e2.type = 0) GROUP BY e2.id ORDER BY a__0 LIMIT 5) AND (e.type = 0) GROUP BY e.id ORDER BY a__0');
 }
开发者ID:ninjapenguin,项目名称:kohana-Doctrine-module,代码行数:17,代码来源:SubqueryTestCase.php

示例12: testMultipleAggregateValuesWithArrayFetching

 public function testMultipleAggregateValuesWithArrayFetching()
 {
     $query = new Doctrine_Query();
     $query->select('u.*, COUNT(DISTINCT b.id) num_books, COUNT(DISTINCT a.id) num_albums');
     $query->from('User u');
     $query->leftJoin('u.Album a, u.Book b');
     $query->where("u.name = 'jon'");
     $query->limit(1);
     $users = $query->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
     try {
         $name = $users[0]['name'];
         $num_albums = $users[0]['num_albums'];
         $num_books = $users[0]['num_books'];
     } catch (Doctrine_Exception $e) {
         $this->fail();
     }
     $this->assertEqual($num_albums, 3);
     $this->assertEqual($num_books, 2);
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:19,代码来源:MultipleAggregateValueTestCase.php

示例13: rec_query_page

 /**
  * Add a limit/offset to a Doctrine_Query.
  *
  * @param Doctrine_Query $q
  * @param int   $limit
  * @param int   $offset
  */
 protected function rec_query_page(Doctrine_Query $q, $limit, $offset)
 {
     if ($limit > 0) {
         $q->limit($limit);
     }
     if ($offset > 0) {
         $q->offset($offset);
     }
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:16,代码来源:DOCframe_Resource.php

示例14: getItems

 /**
  * Returns an array of items for a page.
  *
  * @param  integer $offset Page offset
  * @param  integer $itemCountPerPage Number of items per page
  * @return array
  */
 public function getItems($offset, $itemCountPerPage)
 {
     $this->_query->limit($itemCountPerPage)->offset($offset);
     return $this->_query->execute();
 }
开发者ID:laiello,项目名称:vinhloi,代码行数:12,代码来源:Doctrine.php

示例15: hookLimit

 /**
  * set the hook limit 
  * 
  * @param integer $limit 
  * @return void
  */
 public function hookLimit($limit)
 {
     $this->query->limit((int) $limit);
 }
开发者ID:darkcolonist,项目名称:kohana234-doctrine115,代码行数:10,代码来源:Hook.php


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