*
* @return Bool operation success. true if already closed.
*/
- function close() {
- # Stub, should probably be overridden
- return true;
+ public function close() {
+ $this->mOpened = false;
+ if ( $this->mConn ) {
+ if ( $this->trxLevel() ) {
+ $this->commit( __METHOD__ );
+ }
+ $ret = $this->closeConnection();
+ $this->mConn = false;
+ return $ret;
+ } else {
+ return true;
+ }
}
+ /**
+ * Closes underlying database connection
+ * @since 1.20
+ * @return bool: Whether connection was closed successfully
+ */
+ protected abstract function closeConnection();
+
/**
* @param $error String: fallback error message, used if none is given by DB
*/
* Returns success, true if already closed
* @return bool
*/
- public function close() {
- $this->mOpened = false;
- if ( $this->mConn ) {
- if ( $this->trxLevel() > 0 ) {
- $this->commit( __METHOD__ );
- }
- $ret = db2_close( $this->mConn );
- $this->mConn = null;
- return $ret;
- } else {
- return true;
- }
+ protected function closeConnection() {
+ return db2_close( $this->mConn );
}
/**
* Returns success, true if already closed
* @return bool
*/
- function close() {
- $this->mOpened = false;
- if ( $this->mConn ) {
- $ret = sqlsrv_close( $this->mConn );
- $this->mConn = null;
- return $ret;
- } else {
- return true;
- }
+ protected function closeConnection() {
+ return sqlsrv_close( $this->mConn );
}
protected function doQuery( $sql ) {
/**
* @return bool
*/
- function close() {
- $this->mOpened = false;
- if ( $this->mConn ) {
- if ( $this->trxLevel() ) {
- $this->commit( __METHOD__ );
- }
- $ret = mysql_close( $this->mConn );
- $this->mConn = false;
- return $ret;
- } else {
- return true;
- }
+ protected function closeConnection() {
+ return mysql_close( $this->mConn );
}
/**
* Returns success, true if already closed
* @return bool
*/
- function close() {
- $this->mOpened = false;
- if ( $this->mConn ) {
- if ( $this->mTrxLevel ) {
- $this->commit( __METHOD__ );
- }
- $ret = oci_close( $this->mConn );
- $this->mConn = null;
- return null;
- } else {
- return true;
- }
+ protected function closeConnection() {
+ return oci_close( $this->mConn );
}
function execFlags() {
* Returns success, true if already closed
* @return bool
*/
- function close() {
- $this->mOpened = false;
- if ( $this->mConn ) {
- $ret = pg_close( $this->mConn );
- $this->mConn = null;
- return $ret;
- } else {
- return true;
- }
+ protected function closeConnection() {
+ return pg_close( $this->mConn );
}
protected function doQuery( $sql ) {
}
/**
- * Close an SQLite database
- *
+ * Does not actually close the connection, just destroys the reference for GC to do its work
* @return bool
*/
- function close() {
- $this->mOpened = false;
- if ( is_object( $this->mConn ) ) {
- if ( $this->trxLevel() ) $this->commit( __METHOD__ );
- $this->mConn = null;
- }
+ protected function closeConnection() {
+ $this->mConn = null;
return true;
}