function StatementBase::setFetchMode
Overrides StatementInterface::setFetchMode
3 calls to StatementBase::setFetchMode()
- StatementPrefetchIterator::execute in core/
lib/ Drupal/ Core/ Database/ StatementPrefetchIterator.php - Executes a prepared statement.
- StatementWrapperIterator::execute in core/
lib/ Drupal/ Core/ Database/ StatementWrapperIterator.php - Executes a prepared statement.
- StatementWrapperIterator::__construct in core/
lib/ Drupal/ Core/ Database/ StatementWrapperIterator.php - Constructs a StatementWrapperIterator object.
File
-
core/
lib/ Drupal/ Core/ Database/ Statement/ StatementBase.php, line 181
Class
- StatementBase
- StatementInterface base implementation.
Namespace
Drupal\Core\Database\StatementCode
public function setFetchMode($mode, $a1 = NULL, $a2 = []) {
if (is_int($mode)) {
@trigger_error("Passing the \$mode argument as an integer to setFetchMode() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \\Drupal\\Core\\Database\\FetchAs enum instead. See https://www.drupal.org/node/3488338", E_USER_DEPRECATED);
$mode = $this->pdoToFetchAs($mode);
}
assert($mode instanceof FetchAs);
$this->fetchMode = $mode;
switch ($mode) {
case FetchAs::ClassObject:
$this->fetchOptions['class'] = $a1;
if ($a2) {
$this->fetchOptions['constructor_args'] = $a2;
}
break;
case FetchAs::Column:
$this->fetchOptions['column'] = $a1;
break;
}
// If the result object is missing, just do with the properties setting.
try {
if ($this->result) {
return $this->result
->setFetchMode($mode, $this->fetchOptions);
}
return TRUE;
} catch (\LogicException) {
return TRUE;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.