$this->$var = $params[$var];
}
}
- $this->sqlMode = $params['sqlMode'] ?? '';
+ $this->sqlMode = $params['sqlMode'] ?? null;
$this->utf8Mode = !empty( $params['utf8Mode'] );
$this->insertSelectIsSafe = isset( $params['insertSelectIsSafe'] )
? (bool)$params['insertSelectIsSafe'] : null;
}
}
+ protected function doSelectDomain( DatabaseDomain $domain ) {
+ if ( $domain->getSchema() !== null ) {
+ throw new DBExpectedError( $this, __CLASS__ . ": domain schemas are not supported." );
+ }
+
+ $database = $domain->getDatabase();
+ // A null database means "don't care" so leave it as is and update the table prefix
+ if ( $database === null ) {
+ $this->currentDomain = new DatabaseDomain(
+ $this->currentDomain->getDatabase(),
+ null,
+ $domain->getTablePrefix()
+ );
+
+ return true;
+ }
+
+ if ( $database !== $this->getDBname() ) {
+ $sql = 'USE ' . $this->addIdentifierQuotes( $database );
+ $ret = $this->doQuery( $sql );
+ if ( $ret === false ) {
+ $error = $this->lastError();
+ $errno = $this->lastErrno();
+ $this->reportQueryError( $error, $errno, $sql, __METHOD__ );
+ }
+ }
+
+ // Update that domain fields on success (no exception thrown)
+ $this->currentDomain = $domain;
+
+ return true;
+ }
+
/**
* Open a connection to a MySQL server
*
abstract protected function mysqlSetCharset( $charset );
/**
- * @param ResultWrapper|resource $res
+ * @param IResultWrapper|resource $res
* @throws DBUnexpectedError
*/
public function freeResult( $res ) {
abstract protected function mysqlFreeResult( $res );
/**
- * @param ResultWrapper|resource $res
+ * @param IResultWrapper|resource $res
* @return stdClass|bool
* @throws DBUnexpectedError
*/
/**
* @throws DBUnexpectedError
- * @param ResultWrapper|resource $res
+ * @param IResultWrapper|resource $res
* @return int
*/
function numRows( $res ) {
abstract protected function mysqlNumRows( $res );
/**
- * @param ResultWrapper|resource $res
+ * @param IResultWrapper|resource $res
* @return int
*/
public function numFields( $res ) {
abstract protected function mysqlNumFields( $res );
/**
- * @param ResultWrapper|resource $res
+ * @param IResultWrapper|resource $res
* @param int $n
* @return string
*/
/**
* Get the name of the specified field in a result
*
- * @param ResultWrapper|resource $res
+ * @param IResultWrapper|resource $res
* @param int $n
* @return string
*/
/**
* mysql_field_type() wrapper
- * @param ResultWrapper|resource $res
+ * @param IResultWrapper|resource $res
* @param int $n
* @return string
*/
/**
* Get the type of the specified field in a result
*
- * @param ResultWrapper|resource $res
+ * @param IResultWrapper|resource $res
* @param int $n
* @return string
*/
abstract protected function mysqlFieldType( $res, $n );
/**
- * @param ResultWrapper|resource $res
+ * @param IResultWrapper|resource $res
* @param int $row
* @return bool
*/
/**
* Move internal result pointer
*
- * @param ResultWrapper|resource $res
+ * @param IResultWrapper|resource $res
* @param int $row
* @return bool
*/
$oldName = $this->addIdentifierQuotes( $oldName );
$query = "CREATE $tmp TABLE $newName (LIKE $oldName)";
- return $this->query( $query, $fname );
+ return $this->query( $query, $fname, $this::QUERY_PSEUDO_PERMANENT );
}
/**
/**
* @param string $tableName
* @param string $fName
- * @return bool|ResultWrapper
+ * @return bool|IResultWrapper
*/
public function dropTable( $tableName, $fName = __METHOD__ ) {
if ( !$this->tableExists( $tableName, $fName ) ) {