return false;
}
- /**
- * Usually aborts on failure
- * @param string $server
- * @param string $user
- * @param string $password
- * @param string $dbName
- * @throws DBConnectionError
- * @return resource|null
- */
function open( $server, $user, $password, $dbName ) {
global $wgDBOracleDRCP;
if ( !function_exists( 'oci_connect' ) ) {
$this->doQuery( 'ALTER SESSION SET NLS_TIMESTAMP_TZ_FORMAT=\'DD-MM-YYYY HH24:MI:SS.FF6\'' );
$this->doQuery( 'ALTER SESSION SET NLS_NUMERIC_CHARACTERS=\'.,\'' );
- return $this->conn;
+ return (bool)$this->conn;
}
/**
return $this->__call( __FUNCTION__, func_get_args() );
}
- public function open( $server, $user, $password, $dbName ) {
- return $this->__call( __FUNCTION__, func_get_args() );
- }
-
public function fetchObject( $res ) {
return $this->__call( __FUNCTION__, func_get_args() );
}
}
}
+ /**
+ * 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
*
parent::__construct( $params );
}
- /**
- * Usually aborts on failure
- * @param string $server
- * @param string $user
- * @param string $password
- * @param string $dbName
- * @throws DBConnectionError
- * @return bool|resource|null
- */
- public function open( $server, $user, $password, $dbName ) {
+ protected function open( $server, $user, $password, $dbName ) {
# Test for driver support, to avoid suppressed fatal error
if ( !function_exists( 'sqlsrv_connect' ) ) {
throw new DBConnectionError(
$this->opened = true;
- return $this->conn;
+ return (bool)$this->conn;
}
/**
return 'mysql';
}
- /**
- * @param string $server
- * @param string $user
- * @param string $password
- * @param string $dbName
- * @throws Exception|DBConnectionError
- * @return bool
- */
- public function open( $server, $user, $password, $dbName ) {
+ protected function open( $server, $user, $password, $dbName ) {
# Close/unset connection handle
$this->close();
return false;
}
- public function open( $server, $user, $password, $dbName ) {
+ protected function open( $server, $user, $password, $dbName ) {
# Test for Postgres support, to avoid suppressed fatal error
if ( !function_exists( 'pg_connect' ) ) {
throw new DBConnectionError(
return false;
}
- /** Open an SQLite database and return a resource handle to it
- * NOTE: only $dbName is used, the other parameters are irrelevant for SQLite databases
- *
- * @param string $server
- * @param string $user Unused
- * @param string $pass
- * @param string $dbName
- *
- * @throws DBConnectionError
- * @return bool
- */
- function open( $server, $user, $pass, $dbName ) {
+ protected function open( $server, $user, $pass, $dbName ) {
$this->close();
$fileName = self::generateFileName( $this->dbDir, $dbName );
if ( !is_readable( $fileName ) ) {
$this->conn = false;
throw new DBConnectionError( $this, "SQLite database not accessible" );
}
+ // Only $dbName is used, the other parameters are irrelevant for SQLite databases
$this->openFile( $fileName, $dbName );
return (bool)$this->conn;
*/
public function getType();
- /**
- * 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
- */
- public function open( $server, $user, $password, $dbName );
-
/**
* Fetch the next row from the given result object, in object form.
* Fields can be retrieved with $row->fieldname, with fields acting like