function transaction_db_next_id in Transaction 5
Transaction-friendly version of db_next_id(). The default Drupal implementation performs a table lock which will terminate any open transaction.
Parameters
string The un-prefixed table name to fetch and ID for.:
Return value
int The next ID in the sequence.
3 calls to transaction_db_next_id()
- pressflow_transaction_db_next_id in ./
transaction.module - Legacy compatibility wrapper for transaction_db_next_id().
- TransactionTest::testTransactionDBNextID in tests/
transaction.test - Verify the operation of transaction_db_next_id().
- transaction_update in ./
transaction.module - Utility function that abstracts transactionalized updates or inserts on a single row.
File
- ./
transaction.module, line 98 - Provides a database transaction system for use with InnoDB tables in MySQL.
Code
function transaction_db_next_id($name) {
$name = db_prefix_tables($name);
// Reset LAST_INSERT_ID so it doesn't have a stale value if INSERT succeeds.
db_query('SELECT LAST_INSERT_ID(1)');
db_query('INSERT INTO {sequences} VALUES ("%s", 1) ON DUPLICATE KEY UPDATE id = LAST_INSERT_ID(id + 1)', $name);
$id = db_result(db_query('SELECT LAST_INSERT_ID()'));
return $id;
}