public function DatabaseConnection_sqlsrv::PDOPrepare in Drupal driver for SQL Server and SQL Azure 7.2
Same name and namespace in other branches
- 7.3 sqlsrv/database.inc \DatabaseConnection_sqlsrv::PDOPrepare()
- 7 sqlsrv/database.inc \DatabaseConnection_sqlsrv::PDOPrepare()
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 DatabaseConnection_sqlsrv::PDOPrepare()
- DatabaseConnection_sqlsrv::prepareQuery in sqlsrv/
database.inc - Temporary override of DatabaseConnection::prepareQuery().
File
- sqlsrv/
database.inc, line 275 - Database interface code for Microsoft SQL Server.
Class
- DatabaseConnection_sqlsrv
- Summary of DatabaseConnection_sqlsrv
Code
public function PDOPrepare($query, array $options = array()) {
// Preprocess the query.
if (!$this->bypassQueryPreprocess) {
$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 (DatabaseUtils::GetConfigBoolean('MSSQL_APPEND_CALLSTACK_COMMENT') == TRUE) {
global $user;
$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:' . (empty($user) ? 'null' : $user->uid) . 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);
}