const STATUS_TRX_NONE = 3;
/**
- * @note: exceptions for missing libraries/drivers should be thrown in initConnection()
+ * @note exceptions for missing libraries/drivers should be thrown in initConnection()
* @param array $params Parameters passed from Database::factory()
*/
protected function __construct( array $params ) {
return $column;
}
+ public function lockForUpdate(
+ $table, $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
+ ) {
+ if ( !$this->trxLevel && !$this->getFlag( self::DBO_TRX ) ) {
+ throw new DBUnexpectedError(
+ $this,
+ __METHOD__ . ': no transaction is active nor is DBO_TRX set'
+ );
+ }
+
+ $options = (array)$options;
+ $options[] = 'FOR UPDATE';
+
+ return $this->selectRowCount( $table, '*', $conds, $fname, $options, $join_conds );
+ }
+
/**
* Removes most variables from an SQL query and replaces them with X or N for numbers.
* It's only slightly flawed. Don't use for anything important.
$this->assertOpen();
$this->runOnTransactionPreCommitCallbacks();
+
$writeTime = $this->pendingWriteQueryDuration( self::ESTIMATE_DB_APPLY );
$this->doCommit( $fname );
$this->trxStatus = self::STATUS_TRX_NONE;
+
if ( $this->trxDoneWrites ) {
$this->lastWriteTime = microtime( true );
$this->trxProfiler->transactionWritingOut(
// Avoid fatals if close() was called
$this->assertOpen();
+ $writeTime = $this->pendingWriteQueryDuration( self::ESTIMATE_DB_APPLY );
$this->doRollback( $fname );
$this->trxStatus = self::STATUS_TRX_NONE;
$this->trxAtomicLevels = [];
+
if ( $this->trxDoneWrites ) {
$this->trxProfiler->transactionWritingOut(
$this->server,
$this->dbName,
- $this->trxShortId
+ $this->trxShortId,
+ $writeTime,
+ $this->trxWriteAffectedRows
);
}
}