Merge pull request #7 from halkyon/close_conn_fix

BUG SQLite database connection not closed properly
This commit is contained in:
Mateusz U 2014-10-28 09:53:23 +13:00
commit 6bb7d5a5f6
2 changed files with 17 additions and 1 deletions

View File

@ -106,6 +106,12 @@ class SQLite3Database extends SS_Database {
return true;
}
public function __destruct() {
if($this->dbConn) {
$this->dbConn->close();
}
}
/**
* Not implemented, needed for PDO
*/
@ -1246,7 +1252,9 @@ class SQLite3Query extends SS_Query {
}
public function __destruct() {
if($this->handle) $this->handle->finalize();
if($this->handle) {
$this->handle->finalize();
}
}
public function seek($row) {

View File

@ -55,6 +55,14 @@ class SQLitePDODatabase extends SQLite3Database {
return true;
}
/**
* Overloaded since the parent class tries to call close() on the connection,
* but doing it here won't work as the PDO class has no such method.
*/
public function __destruct() {
// noop
}
public function query($sql, $errorLevel = E_USER_ERROR) {
if(isset($_REQUEST['previewwrite']) && in_array(strtolower(substr($sql,0,strpos($sql,' '))), array('insert','update','delete','replace'))) {