function StatementBase::fetchObject

Overrides StatementInterface::fetchObject

File

core/lib/Drupal/Core/Database/Statement/StatementBase.php, line 251

Class

StatementBase
StatementInterface base implementation.

Namespace

Drupal\Core\Database\Statement

Code

public function fetchObject(?string $className = NULL, array $constructorArguments = []) {
    $row = $className === NULL ? $this->result
        ->fetch(FetchAs::Object, []) : $this->result
        ->fetch(FetchAs::ClassObject, [
        'class' => $className,
        'constructor_args' => $constructorArguments,
    ]);
    if ($row === FALSE) {
        $this->markResultsetFetchingComplete();
        return FALSE;
    }
    $this->setResultsetCurrentRow($row);
    return $row;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.