本文整理匯總了PHP中ResultSet::fetchAllData方法的典型用法代碼示例。如果您正苦於以下問題:PHP ResultSet::fetchAllData方法的具體用法?PHP ResultSet::fetchAllData怎麽用?PHP ResultSet::fetchAllData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ResultSet
的用法示例。
在下文中一共展示了ResultSet::fetchAllData方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: query
/**
* @param DbRequestInterface $request
* @return DbResponseInterface
*/
public function query(DbRequestInterface $request)
{
$mode = MYSQLI_STORE_RESULT;
if (!$request->isResultBuffer()) {
$mode = MYSQLI_USE_RESULT;
}
switch ($request->getResultType()) {
/* column names as keys in the result */
case 'name':
$type = MYSQLI_ASSOC;
break;
/* column position as keys in the result */
/* column position as keys in the result */
case 'position':
$type = MYSQLI_NUM;
break;
case 'name-pos':
$type = MYSQLI_BOTH;
break;
default:
$type = MYSQLI_ASSOC;
}
$sql = $request->getSql();
$filter = $request->getCallback();
$driver = $this->getDriver();
try {
$result = $driver->query($sql, $mode);
} catch (\Exception $e) {
$this->addError($e->getMessage(), $e->getCode());
return false;
}
if (!$result instanceof mysqli_result) {
$this->addError("result not instanceof mysqli_result");
return false;
}
$resultSet = new ResultSet($result);
$data = $resultSet->fetchAllData($type, $filter);
if (false === $data) {
$errText = "{$driver->error} {$drive->sqlstate}";
$errCode = $driver->errno;
$this->addError($errText, $errCode);
return false;
} else {
if (true === $data) {
$data = null;
}
}
return $this->createResponse($data);
}