You are here

public function DatabaseConnection_sqlsrv::queryTemporary in Drupal driver for SQL Server and SQL Azure 7

Same name and namespace in other branches
  1. 7.3 sqlsrv/database.inc \DatabaseConnection_sqlsrv::queryTemporary()
  2. 7.2 sqlsrv/database.inc \DatabaseConnection_sqlsrv::queryTemporary()

Override of DatabaseConnection::queryTemporary().

@status tested

Overrides DatabaseConnection::queryTemporary

File

sqlsrv/database.inc, line 224
Database interface code for Microsoft SQL Server.

Class

DatabaseConnection_sqlsrv

Code

public function queryTemporary($query, array $args = array(), array $options = array()) {

  // Generate a new temporary table name and protect it from prefixing.
  // SQL Server requires that temporary tables to be non-qualified.
  $tablename = '#' . $this
    ->generateTemporaryTableName();
  $prefixes = $this->prefixes;
  $prefixes[$tablename] = '';
  $this
    ->setPrefix($prefixes);

  // Replace SELECT xxx FROM table by SELECT xxx INTO #table FROM table.
  $query = preg_replace('/^SELECT(.*?)FROM/i', 'SELECT$1 INTO ' . $tablename . ' FROM', $query);
  $this
    ->query($query, $args, $options);
  return $tablename;
}