當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。