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.
Deprecated
in drupal:11.5.0 and is removed from drupal:13.0.0. There is no replacement.
See also
https://www.drupal.org/node/3611848
File
-
core/
lib/ Drupal/ Core/ Database/ Statement/ PdoTrait.php, line 72
Class
- PdoTrait
- A trait for calling \PDOStatement methods.
Namespace
Drupal\Core\Database\StatementCode
protected function pdoToFetchAs(int $mode) : FetchAs {
@trigger_error(__METHOD__ . '() is deprecated in drupal:11.5.0 and is removed from drupal:13.0.0. There is no replacement. See https://www.drupal.org/node/3611848', E_USER_DEPRECATED);
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.