function LoggedStatementsTrait::query
Same name in other branches
- 9 core/modules/system/tests/modules/database_statement_monitoring_test/src/LoggedStatementsTrait.php \Drupal\database_statement_monitoring_test\LoggedStatementsTrait::query()
- 8.9.x core/modules/system/tests/modules/database_statement_monitoring_test/src/LoggedStatementsTrait.php \Drupal\database_statement_monitoring_test\LoggedStatementsTrait::query()
File
-
core/
modules/ system/ tests/ modules/ database_statement_monitoring_test/ src/ LoggedStatementsTrait.php, line 27
Class
- LoggedStatementsTrait
- Trait for Connection classes that can store logged statements.
Namespace
Drupal\database_statement_monitoring_testCode
public function query($query, array $args = [], $options = []) {
// Log the query if it is a string, can receive statement objects e.g
// in the pgsql driver. These are hard to log as the table name has already
// been replaced.
if (is_string($query)) {
$stringified_args = array_map(function ($v) {
return is_array($v) ? implode(',', $v) : $v;
}, $args);
$this->loggedStatements[] = str_replace(array_keys($stringified_args), array_values($stringified_args), $query);
}
return parent::query($query, $args, $options);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.