mDb = wfGetLB()->getLazyConnectionRef( DB_MASTER ); $this->mWithTransaction = $withTransaction; $this->mHasTransaction = false; } /** * Begin a database transaction, if $withTransaction was given as true in * the constructor for this SqlDataUpdate. * * Because nested transactions are not supported by the Database class, * this implementation checks Database::trxLevel() and only opens a * transaction if none is already active. */ public function beginTransaction() { if ( !$this->mWithTransaction ) { return; } // NOTE: nested transactions are not supported, only start a transaction if none is open if ( $this->mDb->trxLevel() === 0 ) { $this->mDb->begin( get_class( $this ) . '::beginTransaction' ); $this->mHasTransaction = true; } } /** * Commit the database transaction started via beginTransaction (if any). */ public function commitTransaction() { if ( $this->mHasTransaction ) { $this->mDb->commit( get_class( $this ) . '::commitTransaction' ); $this->mHasTransaction = false; } } /** * Abort the database transaction started via beginTransaction (if any). */ public function abortTransaction() { if ( $this->mHasTransaction ) { // XXX: actually... maybe always? $this->mDb->rollback( get_class( $this ) . '::abortTransaction' ); $this->mHasTransaction = false; } } }