public function DatabaseConnection_sqlsrv::nextId in Drupal driver for SQL Server and SQL Azure 7
Same name and namespace in other branches
- 7.3 sqlsrv/database.inc \DatabaseConnection_sqlsrv::nextId()
- 7.2 sqlsrv/database.inc \DatabaseConnection_sqlsrv::nextId()
Override of DatabaseConnection::nextId().
@status tested
Overrides DatabaseConnection::nextId
File
- sqlsrv/
database.inc, line 436 - Database interface code for Microsoft SQL Server.
Class
Code
public function nextId($existing = 0) {
// If an exiting value is passed, for its insertion into the sequence table.
if ($existing > 0) {
try {
$this
->query('SET IDENTITY_INSERT {sequences} ON; INSERT INTO {sequences} (value) VALUES(:existing); SET IDENTITY_INSERT {sequences} OFF', array(
':existing' => $existing,
));
} catch (Exception $e) {
// Doesn't matter if this fails, it just means that this value is already
// present in the table.
}
}
return $this
->query('INSERT INTO {sequences} DEFAULT VALUES', array(), array(
'return' => Database::RETURN_INSERT_ID,
));
}