function StatementPrefetchIterator::fetchObject
Fetches the next row and returns it as an object.
The object will be of the class specified by StatementInterface::setFetchMode() or stdClass if not specified.
phpcs:disable Drupal.Commenting @todo Uncomment new method parameters before drupal:11.0.0.
Parameters
string|null $class_name: Name of the created class.
array $constructor_arguments: Elements of this array are passed to the constructor. phpcs:enable
Return value
mixed The object of specified class or \stdClass if not specified. Returns FALSE or NULL if there is no next row.
Overrides StatementInterface::fetchObject
File
-
core/
lib/ Drupal/ Core/ Database/ StatementPrefetchIterator.php, line 304
Class
- StatementPrefetchIterator
- An implementation of StatementInterface that prefetches all data.
Namespace
Drupal\Core\DatabaseCode
public function fetchObject(?string $class_name = NULL, array $constructor_arguments = []) {
if (!isset($class_name)) {
return $this->fetch(\PDO::FETCH_OBJ);
}
$this->fetchOptions = [
'class' => $class_name,
'constructor_args' => $constructor_arguments,
];
return $this->fetch(\PDO::FETCH_CLASS);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.