function PdoTrait::pdoToFetchAs
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Database/Statement/PdoTrait.php \Drupal\Core\Database\Statement\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\Statement\FetchAs A FetchAs mode.
File
-
core/
lib/ Drupal/ Core/ Database/ Statement/ PdoTrait.php, line 63
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.