function PdoTrait::clientFetchAll
Returns an array containing all of the result set rows.
Parameters
\Drupal\Core\Database\Statement\FetchAs|null $mode: (Optional) one of the cases of the FetchAs enum. If not specified, defaults to what is specified by setFetchMode().
int|class-string|null $columnOrClass: If $mode is FetchAs::Column, the index of the column to fetch. If $mode is FetchAs::ClassObject, the FQCN of the object.
list<mixed>|null $constructorArguments: If $mode is FetchAs::ClassObject, the arguments to pass to the constructor.
Return value
array<array<scalar|null>|object|scalar|null> An array of results.
2 calls to PdoTrait::clientFetchAll()
- PdoResult::fetchAll in core/
lib/ Drupal/ Core/ Database/ Statement/ PdoResult.php - Returns an array containing all of the result set rows.
- StatementPrefetchIterator::execute in core/
lib/ Drupal/ Core/ Database/ StatementPrefetchIterator.php - Executes a prepared statement.
File
-
core/
lib/ Drupal/ Core/ Database/ Statement/ PdoTrait.php, line 185
Class
- PdoTrait
- A trait for calling \PDOStatement methods.
Namespace
Drupal\Core\Database\StatementCode
protected function clientFetchAll(?FetchAs $mode = NULL, int|string|null $columnOrClass = NULL, array|null $constructorArguments = NULL) : array {
return match ($mode) { FetchAs::Column => $this->getClientStatement()
->fetchAll(\PDO::FETCH_COLUMN, $columnOrClass ?? $this->fetchOptions['column']),
FetchAs::ClassObject => $this->getClientStatement()
->fetchAll(\PDO::FETCH_CLASS, $columnOrClass ?? $this->fetchOptions['class'], $constructorArguments ?? $this->fetchOptions['constructor_args']),
default => $this->getClientStatement()
->fetchAll($this->fetchAsToPdo($mode ?? $this->fetchMode)),
};
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.