function PdoTrait::pdoToFetchAs
Converts a \PDO::FETCH_* constant value to a FetchAs mode.
Parameters
int $mode: The \PDO::FETCH_* constant value.
Return value
\Drupal\Core\Database\FetchAs A FetchAs mode.
8 calls to PdoTrait::pdoToFetchAs()
- StatementPrefetchIterator::fetch in core/
lib/ Drupal/ Core/ Database/ StatementPrefetchIterator.php - Fetches the next row from a result set.
- StatementPrefetchIterator::fetchAll in core/
lib/ Drupal/ Core/ Database/ StatementPrefetchIterator.php - Returns an array containing all of the result set rows.
- StatementPrefetchIterator::fetchAllAssoc in core/
lib/ Drupal/ Core/ Database/ StatementPrefetchIterator.php - Returns the result set as an associative array keyed by the given field.
- StatementPrefetchIterator::setFetchMode in core/
lib/ Drupal/ Core/ Database/ StatementPrefetchIterator.php - Sets the default fetch mode for this statement.
- StatementWrapperIterator::fetch in core/
lib/ Drupal/ Core/ Database/ StatementWrapperIterator.php - Fetches the next row from a result set.
File
-
core/
lib/ Drupal/ Core/ Database/ Statement/ PdoTrait.php, line 40
Class
- PdoTrait
- A trait for calling \PDOStatement methods.
Namespace
Drupal\Core\Database\StatementCode
protected function pdoToFetchAs(int $mode) : FetchAs {
return match ($mode) { \PDO::FETCH_ASSOC => FetchAs::Associative,
\PDO::FETCH_CLASS, \PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE => FetchAs::ClassObject,
\PDO::FETCH_COLUMN => FetchAs::Column,
\PDO::FETCH_NUM => FetchAs::List,
\PDO::FETCH_OBJ => FetchAs::Object,
default => throw new \RuntimeException('Fetch mode ' . ($this->fetchModeLiterals[$mode] ?? $mode) . ' is not supported. Use supported modes only.'),
};
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.