/** @var int[] Prior flags member variable values */
private $priorFlags = [];
- /** @var object|string Class name or object With profileIn/profileOut methods */
+ /** @var mixed Class name or object With profileIn/profileOut methods */
protected $profiler;
/** @var TransactionProfiler */
protected $trxProfiler;
}
}
+ /**
+ * Open a new connection to the database (closing any existing one)
+ *
+ * @param string $server Database server host
+ * @param string $user Database user name
+ * @param string $password Database user password
+ * @param string $dbName Database name
+ * @return bool
+ * @throws DBConnectionError
+ */
+ abstract protected function open( $server, $user, $password, $dbName );
+
/**
* Construct a Database subclass instance given a database type and parameters
*
if ( $this->trxLevel && !$this->trxDoneWrites && $isWrite ) {
$this->trxDoneWrites = true;
$this->trxProfiler->transactionWritingIn(
- $this->server, $this->dbName, $this->trxShortId );
+ $this->server, $this->getDomainID(), $this->trxShortId );
}
if ( $this->getFlag( self::DBO_DEBUG ) ) {
- $this->queryLogger->debug( "{$this->dbName} {$commentedSql}" );
+ $this->queryLogger->debug( "{$this->getDomainID()} {$commentedSql}" );
}
# Send the query to the server and fetch any corresponding errors
}
$this->trxProfiler->recordQueryCompletion(
- $queryProf, $startTime, $isWrite, $this->affectedRows()
+ $queryProf,
+ $startTime,
+ $isWrite,
+ $isWrite ? $this->affectedRows() : $this->numRows( $ret )
);
$this->queryLogger->debug( $sql, [
'method' => $fname,
list( $phpCallback ) = $callback;
$phpCallback( $this );
} catch ( Exception $ex ) {
- $this->errorLogger( $ex );
+ ( $this->errorLogger )( $ex );
$e = $e ?: $ex;
}
}
$this->lastWriteTime = microtime( true );
$this->trxProfiler->transactionWritingOut(
$this->server,
- $this->dbName,
+ $this->getDomainID(),
$this->trxShortId,
$writeTime,
$this->trxWriteAffectedRows
if ( $this->trxDoneWrites ) {
$this->trxProfiler->transactionWritingOut(
$this->server,
- $this->dbName,
+ $this->getDomainID(),
$this->trxShortId,
$writeTime,
$this->trxWriteAffectedRows
* a wrapper. Nowadays, raw database objects are never exposed to external
* callers, so this is unnecessary in external code.
*
- * @param bool|ResultWrapper|resource|object $result
+ * @param bool|ResultWrapper|resource $result
* @return bool|ResultWrapper
*/
protected function resultObject( $result ) {
*/
public function __clone() {
$this->connLogger->warning(
- "Cloning " . static::class . " is not recomended; forking connection:\n" .
+ "Cloning " . static::class . " is not recommended; forking connection:\n" .
( new RuntimeException() )->getTraceAsString()
);