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


PHP Zend_Db::fetchOne方法代码示例

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


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

示例1: setup

 /**
  * Creates and populates the DataSource
  *
  * @access public
  * @return void
  **/
 public function setup()
 {
     $select = $this->getSelect();
     if ($this->paginate) {
         $sql = $this->getSelectCountSql();
         $this->totalRows = (int) $this->_db->fetchOne($sql);
         list($start, $total) = $this->limit;
         $select->reset(Zend_Db_Select::LIMIT_COUNT);
         $select->reset(Zend_Db_Select::LIMIT_OFFSET);
         $select->limit($total, $start);
     } else {
         $this->totalRows = 0;
     }
     $select->reset(Zend_Db_Select::ORDER);
     if (count($this->order) > 0) {
         $select->order($this->order);
     }
     // Fetch Select Columns
     $rawColumns = $select->getPart(Zend_Db_Select::COLUMNS);
     $columns = array();
     // Get columns and Force casting as strings
     foreach ($rawColumns as $col) {
         $columns[] = (string) $col[1];
     }
     $this->cols = $columns;
     $this->totalColumns = count($columns);
     // Fetch
     $stmt = $this->_db->query($select);
     $rows = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
     $total = count($rows);
     $this->totalRowset = $total;
     $this->rows = $rows;
 }
开发者ID:gatorv,项目名称:gecko_fw1,代码行数:39,代码来源:Select.php

示例2: count

 /**
  * Implements countable, returns count of records
  */
 public function count()
 {
     if ($this->_count !== false) {
         return $this->_count;
     }
     // Originally, we chose to replace the selected fields part of the query with a COUNT(*), however
     // we ran into several conditions where this would not work such as if the query has a join, a limit,
     // a group by, a sub-select as a field, or orders by a derived field.  Therefore, we do a sub-select
     // of our own to find the count.
     $this->_count = (int) $this->_zendDb->fetchOne('SELECT COUNT(*) as rowCount FROM (' . $this->query() . ') as t1');
     return $this->_count;
 }
开发者ID:jfro,项目名称:php-simpledb,代码行数:15,代码来源:List.php


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