本文整理汇总了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;
}