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


PHP Zend_Db_Adapter_Abstract::limit方法代码示例

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


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

示例1: _query

 /**
  * 查询记录
  *
  * @param string $where
  * @return array
  */
 protected function _query($where)
 {
     $order = $this->_getOrder();
     $sql = "SELECT {$this->_columns} FROM {$this->_table} {$where} {$order}";
     $offset = $this->_pageSize * ($this->_currentPage - 1);
     $sql = $this->_db->limit($sql, $this->_pageSize, $offset);
     return $this->_db->fetchAll($sql);
 }
开发者ID:bjtenao,项目名称:tudu-web,代码行数:14,代码来源:Paginator.php

示例2: _renderLimitoffset

 /**
  * Render LIMIT OFFSET clause
  *
  * @param string   $sql SQL query
  * @return string
  */
 protected function _renderLimitoffset($sql)
 {
     $count = 0;
     $offset = 0;
     if (!empty($this->_parts[self::LIMIT_OFFSET])) {
         $offset = (int) $this->_parts[self::LIMIT_OFFSET];
         $count = PHP_INT_MAX;
     }
     if (!empty($this->_parts[self::LIMIT_COUNT])) {
         $count = (int) $this->_parts[self::LIMIT_COUNT];
     }
     /*
      * Add limits clause
      */
     if ($count > 0) {
         $sql = trim($this->_adapter->limit($sql, $count, $offset));
     }
     return $sql;
 }
开发者ID:NerdGZ,项目名称:icingaweb2,代码行数:25,代码来源:Select.php

示例3: _renderLimitoffset

 /**
  * Render LIMIT OFFSET clause
  *
  * @param string   $sql SQL query
  * @return string
  */
 protected function _renderLimitoffset($sql)
 {
     $count = 0;
     $offset = 0;
     if (!empty($this->_parts[self::LIMIT_OFFSET])) {
         $offset = (int) $this->_parts[self::LIMIT_OFFSET];
         // This should reduce to the max integer PHP can support
         $count = intval(9223372036854775807);
     }
     if (!empty($this->_parts[self::LIMIT_COUNT])) {
         $count = (int) $this->_parts[self::LIMIT_COUNT];
     }
     /*
      * Add limits clause
      */
     if ($count > 0) {
         $sql = trim($this->_adapter->limit($sql, $count, $offset));
     }
     return $sql;
 }
开发者ID:Mendim,项目名称:gtv-resources,代码行数:26,代码来源:Select.php

示例4: testExceptionInvalidLimitArgument

 public function testExceptionInvalidLimitArgument()
 {
     $table = $this->getIdentifier(self::TABLE_NAME);
     $exceptionSeen = false;
     try {
         $sql = $this->_db->limit('SELECT * FROM ' . $this->_db->quoteIdentifier($table), 0);
     } catch (Exception $e) {
         $this->assertThat($e, $this->isInstanceOf('Zend_Db_Adapter_Exception'), 'Expecting object of type Zend_Db_Adapter_Exception');
         $exceptionSeen = true;
     }
     $this->assertTrue($exceptionSeen);
     $exceptionSeen = false;
     try {
         $sql = $this->_db->limit('SELECT * FROM ' . $this->_db->quoteIdentifier($table), 1, -1);
     } catch (Exception $e) {
         $this->assertThat($e, $this->isInstanceOf('Zend_Db_Adapter_Exception'), 'Expecting object of type Zend_Db_Adapter_Exception');
         $exceptionSeen = true;
     }
     $this->assertTrue($exceptionSeen);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:20,代码来源:Common.php

示例5: limit

 /**
  * Adds an adapter-specific LIMIT clause to the SELECT statement.
  *
  * @param mixed   $sql    sql clause
  * @param integer $count  count
  * @param integer $offset offset
  * @return string
  */
 public function limit($sql, $count, $offset = 0)
 {
     return $this->_adapter->limit($sql, $count, $offset);
 }
开发者ID:cwcw,项目名称:cms,代码行数:12,代码来源:Abstract.php

示例6: __toString


//.........这里部分代码省略.........
             foreach ($columnList as $alias => $column) {
                 if (!is_string($alias)) {
                     $alias = null;
                 }
                 if ($column instanceof Zend_Db_Expr) {
                     $columns[] = $this->_adapter->quoteColumnAs($column, $alias);
                 } else {
                     if ($column == '*') {
                         $column = new Zend_Db_Expr('*');
                         $alias = null;
                     }
                     if (empty($correlationName)) {
                         $columns[] = $this->_adapter->quoteColumnAs($column, $alias);
                     } else {
                         $columns[] = $this->_adapter->quoteColumnAs(array($correlationName, $column), $alias);
                     }
                 }
             }
         }
         $sql .= implode(",\n\t", $columns);
     }
     // from these joined tables
     if ($this->_parts[self::FROM]) {
         $from = array();
         // array_pop()
         foreach ($this->_parts[self::FROM] as $correlationName => $table) {
             $tmp = '';
             if (empty($from)) {
                 // First table is named alone ignoring join information
                 $tmp .= $this->_adapter->quoteTableAs($table['tableName'], $correlationName);
             } else {
                 // Subsequent tables may have joins
                 if (!empty($table['joinType'])) {
                     $tmp .= ' ' . strtoupper($table['joinType']) . ' ';
                 }
                 $tmp .= $this->_adapter->quoteTableAs($table['tableName'], $correlationName);
                 if (!empty($table['joinCondition'])) {
                     $tmp .= ' ON ' . $table['joinCondition'];
                 }
             }
             // add the table name and condition
             // add to the list
             $from[] = $tmp;
         }
         // add the list of all joins
         if (!empty($from)) {
             $sql .= "\nFROM " . implode("\n", $from);
         }
         // with these where conditions
         if ($this->_parts[self::WHERE]) {
             $sql .= "\nWHERE\n\t";
             $sql .= implode("\n\t", $this->_parts[self::WHERE]);
         }
         // grouped by these columns
         if ($this->_parts[self::GROUP]) {
             $sql .= "\nGROUP BY\n\t";
             $l = array();
             foreach ($this->_parts[self::GROUP] as $term) {
                 $l[] = $this->_adapter->quoteIdentifier($term);
             }
             $sql .= implode(",\n\t", $l);
         }
         // having these conditions
         if ($this->_parts[self::HAVING]) {
             $sql .= "\nHAVING\n\t";
             $sql .= implode("\n\t", $this->_parts[self::HAVING]);
         }
     }
     // ordered by these columns
     if ($this->_parts[self::ORDER]) {
         $sql .= "\nORDER BY\n\t";
         $l = array();
         foreach ($this->_parts[self::ORDER] as $term) {
             if (is_array($term)) {
                 $l[] = $this->_adapter->quoteIdentifier($term[0]) . ' ' . $term[1];
             } else {
                 $l[] = $this->_adapter->quoteIdentifier($term);
             }
         }
         $sql .= implode(",\n\t", $l);
     }
     // determine offset
     $count = 0;
     $offset = 0;
     if (!empty($this->_parts[self::LIMIT_OFFSET])) {
         $offset = (int) $this->_parts[self::LIMIT_OFFSET];
         // this should be reduced to the max integer PHP can support
         $count = intval(9223372036854775807);
     }
     // determine count
     if (!empty($this->_parts[self::LIMIT_COUNT])) {
         $count = (int) $this->_parts[self::LIMIT_COUNT];
     }
     // add limits clause
     if ($count > 0) {
         $sql .= "\n";
         $sql = trim($this->_adapter->limit($sql, $count, $offset));
     }
     return $sql;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:101,代码来源:Select.php

示例7: __toString

 /**
  * Converts this object to an SQL SELECT string.
  *
  * @todo use $this->_adapter->quoteColumns() for non-PDO adapters
  * @todo use $this->_adapter->quoteTableNames() for non-PDO adapters
  * @todo use prepared queries for PDO adapters instead of constructing all the SQL ourselves
  *           like in Adapter/Abstract.php.html:query()
  * @return string This object as a SELECT string.
  */
 public function __toString()
 {
     // initial SELECT [DISTINCT] [FOR UPDATE]
     $sql = "SELECT";
     if ($this->_parts['distinct']) {
         $sql .= " DISTINCT";
     }
     if ($this->_parts['forUpdate']) {
         $sql .= " FOR UPDATE";
     }
     $sql .= "\n\t";
     // add columns
     if ($this->_parts['cols']) {
         $sql .= implode(",\n\t", $this->_parts['cols']) . "\n";
     }
     // from these tables
     if ($this->_parts['from']) {
         $sql .= "FROM ";
         $sql .= implode(", ", array_keys($this->_parts['from'])) . "\n";
     }
     // joined to these tables
     if ($this->_parts['join']) {
         $list = array();
         foreach ($this->_parts['join'] as $join) {
             $tmp = '';
             // add the type (LEFT, INNER, etc)
             if (!empty($join['type'])) {
                 $tmp .= strtoupper($join['type']) . ' ';
             }
             // add the table name and condition
             $tmp .= 'JOIN ' . $join['name'];
             $tmp .= ' ON ' . $join['cond'];
             // add to the list
             $list[] = $tmp;
         }
         // add the list of all joins
         $sql .= implode("\n", $list) . "\n";
     }
     // with these where conditions
     if ($this->_parts['where']) {
         $sql .= "WHERE\n\t";
         $sql .= implode("\n\t", $this->_parts['where']) . "\n";
     }
     // grouped by these columns
     if ($this->_parts['group']) {
         $sql .= "GROUP BY\n\t";
         $sql .= implode(",\n\t", $this->_parts['group']) . "\n";
     }
     // having these conditions
     if ($this->_parts['having']) {
         $sql .= "HAVING\n\t";
         $sql .= implode("\n\t", $this->_parts['having']) . "\n";
     }
     // ordered by these columns
     if ($this->_parts['order']) {
         $sql .= "ORDER BY\n\t";
         $sql .= implode(",\n\t", $this->_parts['order']) . "\n";
     }
     // determine count
     $count = !empty($this->_parts['limitCount']) ? (int) $this->_parts['limitCount'] : 0;
     // determine offset
     $offset = !empty($this->_parts['limitOffset']) ? (int) $this->_parts['limitOffset'] : 0;
     // add limits, and done
     return trim($this->_adapter->limit($sql, $count, $offset));
 }
开发者ID:fferriere,项目名称:web,代码行数:74,代码来源:Select.php


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