public function Connection::PDOPrepare in Drupal driver for SQL Server and SQL Azure 8
Internal function: prepare a query by calling PDO directly.
This function has to be public because it is called by other parts of the database layer, but do not call it directly, as you risk locking down the PHP process.
1 call to Connection::PDOPrepare()
- Connection::prepareQuery in drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Connection.php - Temporary override of DatabaseConnection::prepareQuery().
File
- drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Connection.php, line 285 - Definition of Drupal\Driver\Database\sqlsrv\Connection
Class
- Connection
- Temporary tables: temporary table support is done by means of global temporary tables (#) to avoid the use of DIRECT QUERIES. You can enable and disable the use of direct queries with $this->driver_settings->defaultDirectQuery =…
Namespace
Drupal\Driver\Database\sqlsrvCode
public function PDOPrepare($query, array $options = array()) {
// Preprocess the query.
if (!$this->driver_settings
->GetDeafultBypassQueryPreprocess()) {
$query = $this
->preprocessQuery($query);
}
// You can set the MSSQL_APPEND_CALLSTACK_COMMENT to TRUE
// to append to each query, in the form of comments, the current
// backtrace plus other details that aid in debugging deadlocks
// or long standing locks. Use in combination with MSSQL profiler.
global $conf;
if ($this->driver_settings
->GetAppendCallstackComment()) {
$oUser = \Drupal::currentUser();
$uid = NULL;
if ($oUser != NULL) {
$uid = $oUser
->getAccount()
->id();
}
$trim = strlen(DRUPAL_ROOT);
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
static $request_id;
if (empty($request_id)) {
$request_id = uniqid('', TRUE);
}
// Remove las item (it's alwasy PDOPrepare)
$trace = array_splice($trace, 1);
$comment = PHP_EOL . PHP_EOL;
$comment .= '-- uid:' . ($uid ? $uid : 'NULL') . PHP_EOL;
$uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : 'none';
$uri = preg_replace("/[^a-zA-Z0-9]/i", "_", $uri);
$comment .= '-- url:' . $uri . PHP_EOL;
//$comment .= '-- request_id:' . $request_id . PHP_EOL;
foreach ($trace as $t) {
$function = isset($t['function']) ? $t['function'] : '';
$file = '';
if (isset($t['file'])) {
$len = strlen($t['file']);
if ($len > $trim) {
$file = substr($t['file'], $trim, $len - $trim) . " [{$t['line']}]";
}
}
$comment .= '-- ' . str_pad($function, 35) . ' ' . $file . PHP_EOL;
}
$query = $comment . PHP_EOL . $query;
}
return parent::prepare($query, $options);
}