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


PHP Zend_Db_Select::limit方法代码示例

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


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

示例1: getSelect

 /**
  * Returns the select object to be used for validation.
  * @return Zend_Db_Select $select
  */
 public function getSelect()
 {
     if (null === $this->_select) {
         $db = $this->getAdapter();
         // Zend_Debug::dump($this->_excludeId ); // die(0);
         $select = new Zend_Db_Select($db);
         $select->from($this->_table, array($this->_field), $this->_schema);
         if ($db->supportsParameters('named')) {
             $select->where($db->quoteIdentifier($this->_field, true) . ' = :value');
             // named
         } else {
             $select->where($db->quoteIdentifier($this->_field, true) . ' = ?');
             // positional
         }
         $select->limit(1);
         if (!empty($this->_meetingId)) {
             $select->where($db->quoteInto('`meeting_id` = ?', $this->_meetingId));
         }
         if (!empty($this->_excludeId)) {
             $select->where($db->quoteInto('`id` != ?', $this->_excludeId));
         }
         $this->_select = $select;
     }
     return $this->_select;
 }
开发者ID:vrtulka23,项目名称:daiquiri,代码行数:29,代码来源:Email.php

示例2: _query

 /**
  * Run query and returns matches, or null if no matches are found.
  *
  * @param  String $value
  * @return Array when matches are found.
  */
 protected function _query($value)
 {
     /**
      * Check for an adapter being defined. if not, fetch the default adapter.
      */
     if ($this->_adapter === null) {
         $this->_adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     }
     /**
      * Build select object
      */
     $select = new Zend_Db_Select($this->_adapter);
     $select->from($this->_table, array($this->_field), $this->_schema)->where($this->_adapter->quoteIdentifier($this->_field) . ' = ?', $value);
     if ($this->_exclude !== null) {
         if (is_array($this->_exclude)) {
             $select->where($this->_adapter->quoteIdentifier($this->_exclude['field']) . ' != ?', $this->_exclude['value']);
         } else {
             $select->where($this->_exclude);
         }
     }
     $select->limit(1);
     /**
      * Run query
      */
     $result = $this->_adapter->fetchRow($select, array(), Zend_Db::FETCH_ASSOC);
     return $result;
 }
开发者ID:Tony133,项目名称:zf-web,代码行数:33,代码来源:RecordExists.php

示例3: 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)
 {
     // Cast to integers, as $itemCountPerPage can be string sometimes and that would fail later checks
     $offset = (int) $offset;
     $itemCountPerPage = (int) $itemCountPerPage;
     if ($this->_lastOffset === $offset && $this->_lastItemCount === $itemCountPerPage && null !== $this->_lastItems) {
         return $this->_lastItems;
     }
     $this->_lastOffset = $offset;
     $this->_lastItemCount = $itemCountPerPage;
     // Optimization: by using the MySQL feature SQL_CALC_FOUND_ROWS
     // we can get the count and the results in a single query.
     $db = $this->_select->getAdapter();
     if (null === $this->_count && $db instanceof \Zend_Db_Adapter_Mysqli) {
         $this->_select->limit($itemCountPerPage, $offset);
         $sql = $this->_select->__toString();
         if (\MUtil_String::startsWith($sql, 'select ', true)) {
             $sql = 'SELECT SQL_CALC_FOUND_ROWS ' . substr($sql, 7);
         }
         $this->_lastItems = $db->fetchAll($sql);
         $this->_count = $db->fetchOne('SELECT FOUND_ROWS()');
     } else {
         $this->_lastItems = $this->_selectAdapter->getItems($offset, $itemCountPerPage);
     }
     if (is_array($this->_lastItems)) {
         if (isset($this->_model->prefetchIterator) && $this->_model->prefetchIterator) {
             $this->_lastItems = new \ArrayIterator($this->_lastItems);
         }
         $this->_lastItems = $this->_model->processAfterLoad($this->_lastItems, false, false);
     }
     return $this->_lastItems;
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:39,代码来源:SelectModelPaginator.php

示例4: getVesion

 function getVesion()
 {
     $select = new Zend_Db_Select($this->db);
     $select->from('Version', 'VersionId');
     $select->limit(1);
     $res = $this->db->fetchOne($select);
     return $res;
 }
开发者ID:neverstoplwy,项目名称:contrib-webacula,代码行数:8,代码来源:Version.php

示例5: limit

 public function limit($count = null, $offset = null)
 {
     if (is_array($count)) {
         $offset = $count['start'];
         $count = $count['limit'];
     }
     return parent::limit($count, $offset);
 }
开发者ID:koala-framework,项目名称:koala-framework,代码行数:8,代码来源:Select.php

示例6: buildQueryLimit

 /**
  * Set's the query limit
  *
  * @param int $count  Offset Start
  * @param int $offset Offset End
  *
  * @return Zend_Db_Select
  */
 public function buildQueryLimit($count, $offset)
 {
     if ($this->_limit > 0 && $this->_limit < $count) {
         $count = $this->_limit;
     }
     $this->_select->limit($count, $offset);
     return $this;
 }
开发者ID:ocpyosep78,项目名称:Booking,代码行数:16,代码来源:Select.php

示例7: getClientId

 function getClientId($client_name)
 {
     $select = new Zend_Db_Select($this->_db);
     $select->from('Client');
     $select->where("Name = ?", $client_name);
     $select->limit(1);
     $stmt = $select->query();
     $res = $stmt->fetch();
     return $res['clientid'];
 }
开发者ID:staser,项目名称:webacula,代码行数:10,代码来源:Client.php

示例8: search

 public function search($word = null, $limit = null)
 {
     $db = Zend_Registry::get('db');
     $sql = new Zend_Db_Select($db);
     $select = $sql->from('albums');
     if (!is_null($word)) {
         $select = $sql->where($db->quoteInto('title LIKE ? OR artist LIKE ?', "%" . $word . "%"));
     }
     if ($limit > 0) {
         $select = $sql->limit($limit);
     }
     $select = $sql->order('artist DESC');
     $results = $db->query($select);
     $rows = $results->fetchAll();
     return $rows;
 }
开发者ID:rawatanil3,项目名称:Zend-Framework-1.12-Template,代码行数:16,代码来源:Albums.php

示例9: fetchRow

 /**
  * @return array
  */
 public function fetchRow()
 {
     $this->sql_select->limit(1);
     return $this->sql_select->query()->fetch();
 }
开发者ID:harmslijper,项目名称:gemstracker-library,代码行数:8,代码来源:TokenSelect.php

示例10: filterLimitOffset

 /**
  * Extract limit and offset from the filter and add it to a select
  *
  * @param array $filter
  * @param \Zend_Db_Select $select
  */
 protected function filterLimitOffset(&$filter, $select)
 {
     $limit = null;
     $offset = null;
     if (array_key_exists('limit', $filter)) {
         $limit = (int) $filter['limit'];
         unset($filter['limit']);
     }
     if (array_key_exists('offset', $filter)) {
         $offset = (int) $filter['offset'];
         unset($filter['offset']);
     }
     $select->limit($limit, $offset);
 }
开发者ID:harmslijper,项目名称:gemstracker-library,代码行数:20,代码来源:SourceAbstract.php

示例11: fetchRow

 /**
  * fetchRow wrapper
  * This function does not invalidate/store any data on the dataset; All read rows are returned as an array directly
  *
  * @param string|\Zend_Db_Select $sql
  * @param array $params
  * @return mixed Array, object, or scalar depending on fetch mode.
  */
 public function fetchRow($sql, array $params = [])
 {
     if ($sql instanceof \Zend_Db_Select) {
         $sql->limit(1);
     }
     $sql = $this->assembleSql($sql);
     return $this->getReadAdapter()->fetchRow($sql, $params);
 }
开发者ID:cipherpols,项目名称:cze,代码行数:16,代码来源:Dataset.php

示例12: getProduct

 public function getProduct($newsDate = null)
 {
     $start_date = new DateTime();
     $start_date->setTime(20, 0, 0);
     $start_date->setDate($newsDate->format("Y"), $newsDate->format("m"), $newsDate->format("d") - 1);
     $end_date = new DateTime();
     $end_date->setTime(10, 0, 0);
     $end_date->setDate($newsDate->format("Y"), $newsDate->format("m"), $newsDate->format("d"));
     $select = new Zend_Db_Select($this->getDefaultAdapter());
     $select->from(array('c' => $this->_campanha));
     $select->where('start_date = ?', $start_date->format("Y-m-d H:i:s"));
     $select->where('start_date = end_date');
     $select->where('is_banner = ?', '0');
     $select->where('is_magazine = ?', '0');
     $select->where('is_product = ?', '1');
     $select->where('is_active = ?', '1');
     $select->order("priority DESC");
     $select->order("end_date ASC");
     $select->limit(1);
     return $this->_db->fetchAssoc($select);
 }
开发者ID:rafaelcastelani,项目名称:Newsletter,代码行数:21,代码来源:wwnlDB.php

示例13: _query

 /**
  * Overrides _query() from Zend_Validate_Db_Abstract
  * 
  * @param mixed $value 
  * @access protected
  * @return void
  */
 protected function _query($value)
 {
     if ($this->_adapter === NULL) {
         $this->_adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
         if (NULL === $this->_adapter) {
             require_once 'Zend/Validate/Exception.php';
             throw new Zend_Validate_Exception('No database adapter present');
         }
     }
     $select = new Zend_Db_Select($this->_adapter);
     $select->from($this->_table, array($this->_field), $this->_schema);
     if (NULL == $this->_userPkValue) {
         require_once 'Zend/Validate/Exception.php';
         throw new Zend_Validate_Exception('You must specify the value for the primary / unique key');
     }
     $select->where($this->_adapter->quoteIdentifier($this->_userPkField) . ' = ?', $this->_userPkValue);
     if (strpos($this->_treatment, '?') !== FALSE || $this->_treatment instanceof Zend_Db_Expr) {
         $where = $this->_adapter->quoteIdentifier($this->_field) . ' = ' . $this->_treatment;
         $select->where($where, $value);
     } else {
         $value = call_user_func($this->_treatment, $value);
         $select->where($this->_adapter->quoteIdentifier($this->_field) . ' = ?', $value);
     }
     $select->limit(1);
     $result = $this->_adapter->fetchRow($select, array(), Zend_Db::FETCH_ASSOC);
     return $result;
 }
开发者ID:omusico,项目名称:logica,代码行数:34,代码来源:PasswordExists.php

示例14: _refineSelection

 /**
  * Refine the active pastes selection based on criteria provided
  *
  * Allows setting a limit to the number of records returend
  * 
  * @param  Zend_Db_Select $select 
  * @param  array $criteria 
  * @return void
  */
 protected function _refineSelection(Zend_Db_Select $select, array $criteria)
 {
     if (array_key_exists('start', $criteria) && $criteria['start'] == intval($criteria['start'])) {
         if (array_key_exists('count', $criteria) && $criteria['count'] == intval($criteria['count'])) {
             $select->limit($criteria['count'], $criteria['start']);
         }
     }
     $sorted = false;
     if (array_key_exists('sort', $criteria)) {
         $sort = $criteria['sort'];
         $dir = 'ASC';
         if ('-' == substr($sort, 0, 1)) {
             $sort = substr($sort, 1);
             $dir = 'DESC';
         }
         $fields = $this->getTable()->info('cols');
         if (in_array($sort, $fields)) {
             $select->order("{$sort} {$dir}");
             $sorted = true;
         }
     }
     if (!$sorted) {
         $select->order('created DESC');
     }
 }
开发者ID:kadvani1,项目名称:pastebin,代码行数:34,代码来源:Paste.php

示例15: getSelect

 /**
  * Gets the select object to be used by the validator.
  * If no select object was supplied to the constructor,
  * then it will auto-generate one from the given table,
  * schema, field, and adapter options.
  *
  * @return Zend_Db_Select The Select object which will be used
  */
 public function getSelect()
 {
     if (null === $this->_select) {
         $db = $this->getAdapter();
         /**
          * Build select object
          */
         $select = new Zend_Db_Select($db);
         $select->from($this->_table, array($this->_field), $this->_schema);
         if ($db->supportsParameters('named')) {
             $select->where($db->quoteIdentifier($this->_field, true) . ' = :value');
             // named
         } else {
             $select->where($db->quoteIdentifier($this->_field, true) . ' = ?');
             // positional
         }
         if ($this->_exclude !== null) {
             if (is_array($this->_exclude)) {
                 $select->where($db->quoteIdentifier($this->_exclude['field'], true) . ' != ?', $this->_exclude['value']);
             } else {
                 $select->where($this->_exclude);
             }
         }
         $select->limit(1);
         $this->_select = $select;
     }
     return $this->_select;
 }
开发者ID:rapsli,项目名称:404crawler,代码行数:36,代码来源:Abstract.php


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