當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Select::getAdapter方法代碼示例

本文整理匯總了PHP中Zend\Db\Sql\Select::getAdapter方法的典型用法代碼示例。如果您正苦於以下問題:PHP Select::getAdapter方法的具體用法?PHP Select::getAdapter怎麽用?PHP Select::getAdapter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\Db\Sql\Select的用法示例。


在下文中一共展示了Select::getAdapter方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setRowCount

 /**
  * Sets the total row count, either directly or through a supplied
  * query.  Without setting this, {@link getPages()} selects the count
  * as a subquery (SELECT COUNT ... FROM (SELECT ...)).  While this
  * yields an accurate count even with queries containing clauses like
  * LIMIT, it can be slow in some circumstances.  For example, in MySQL,
  * subqueries are generally slow when using the InnoDB storage engine.
  * Users are therefore encouraged to profile their queries to find
  * the solution that best meets their needs.
  *
  * @param  \Zend\Db\Sql\Select|integer $rowCount Total row count integer
  *                                               or query
  * @throws Exception\InvalidArgumentException
  * @return DbSelect
  */
 public function setRowCount($rowCount)
 {
     if ($rowCount instanceof Sql\Select) {
         $columns = $rowCount->getPart(Sql\Select::COLUMNS);
         $countColumnPart = $columns[0][1];
         if ($countColumnPart instanceof Sql\ExpressionInterface) {
             $countColumnPart = $countColumnPart->__toString();
         }
         $rowCountColumn = $this->select->getAdapter()->foldCase(self::ROW_COUNT_COLUMN);
         // The select query can contain only one column, which should be the row count column
         if (false === strpos($countColumnPart, $rowCountColumn)) {
             throw new Exception\InvalidArgumentException('Row count column not found');
         }
         $result = $rowCount->query(Db\Db::FETCH_ASSOC)->fetch();
         $this->rowCount = count($result) > 0 ? $result[$rowCountColumn] : 0;
     } elseif (is_integer($rowCount)) {
         $this->rowCount = $rowCount;
     } else {
         throw new Exception\InvalidArgumentException('Invalid row count');
     }
     return $this;
 }
開發者ID:Rovak,項目名稱:zf2,代碼行數:37,代碼來源:DbSelect.php


注:本文中的Zend\Db\Sql\Select::getAdapter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。