public function DbHelper::__call in MongoDB 8
File
- drivers/
lib/ Drupal/ Driver/ Database/ mongodb/ DbHelper.php, line 28 - Contains \Drupal\Driver\Database\mongodb\TestQuery.
Class
Namespace
Drupal\Driver\Database\mongodbCode
public function __call($name, $args) {
if (in_array($name, [
'query',
'select',
'update',
'insert',
'merge',
'delete',
'truncate',
])) {
$this->calls = [];
$this->hash = [];
}
$this->calls[$name][] = $args;
// Remove variables from various methods and use the results to identify
// the query.
if ($name == 'query') {
$args = $args[0];
}
if ($name == 'condition') {
unset($args[1]);
}
if (!isset($this->calls['select'])) {
if ($name == 'fields' || $name == 'values') {
$keys = array_keys($args[0]);
// Is this a column => value array?
if ($keys !== range(0, count($keys) - 1)) {
// Keep the columns.
$args = $keys;
}
elseif ($name == 'values') {
// If it is just a list of values then discard the whole thing.
$args = [];
}
}
}
$this->hash[$name][] = $args;
$method = 'do' . substr(hash('sha256', serialize($this->hash)), 0, 8);
if (method_exists($this, $method)) {
return call_user_func([
$this,
$method,
]);
}
#file_put_contents('/tmp/log', "$name $method\n", FILE_APPEND);
return $this;
}