summaryrefslogtreecommitdiff
path: root/includes/db/DatabaseSqlite.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/db/DatabaseSqlite.php')
-rw-r--r--includes/db/DatabaseSqlite.php80
1 files changed, 43 insertions, 37 deletions
diff --git a/includes/db/DatabaseSqlite.php b/includes/db/DatabaseSqlite.php
index b2eb1c6b..f1e553d7 100644
--- a/includes/db/DatabaseSqlite.php
+++ b/includes/db/DatabaseSqlite.php
@@ -3,6 +3,21 @@
* This is the SQLite database abstraction layer.
* See maintenance/sqlite/README for development notes and other specific information
*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
* @file
* @ingroup Database
*/
@@ -88,7 +103,7 @@ class DatabaseSqlite extends DatabaseBase {
*
* @param $fileName string
*
- * @return PDO|false SQL connection or false if failed
+ * @return PDO|bool SQL connection or false if failed
*/
function openFile( $fileName ) {
$this->mDatabaseFile = $fileName;
@@ -115,16 +130,11 @@ class DatabaseSqlite extends DatabaseBase {
}
/**
- * 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();
- $this->mConn = null;
- }
+ protected function closeConnection() {
+ $this->mConn = null;
return true;
}
@@ -140,7 +150,7 @@ class DatabaseSqlite extends DatabaseBase {
/**
* Check if the searchindext table is FTS enabled.
- * @return false if not enabled.
+ * @return bool False if not enabled.
*/
function checkForEnabledSearch() {
if ( self::$fulltextEnabled === null ) {
@@ -166,7 +176,7 @@ class DatabaseSqlite extends DatabaseBase {
}
$cachedResult = false;
$table = 'dummy_search_test';
-
+
$db = new DatabaseSqliteStandalone( ':memory:' );
if ( $db->query( "CREATE VIRTUAL TABLE $table USING FTS3(dummy_field)", __METHOD__, true ) ) {
@@ -303,7 +313,7 @@ class DatabaseSqlite extends DatabaseBase {
/**
* @param $res ResultWrapper
- * @param $n
+ * @param $n
* @return bool
*/
function fieldName( $res, $n ) {
@@ -347,7 +357,8 @@ class DatabaseSqlite extends DatabaseBase {
* @return int
*/
function insertId() {
- return $this->mConn->lastInsertId();
+ // PDO::lastInsertId yields a string :(
+ return intval( $this->mConn->lastInsertId() );
}
/**
@@ -497,6 +508,7 @@ class DatabaseSqlite extends DatabaseBase {
/**
* Based on generic method (parent) with some prior SQLite-sepcific adjustments
+ * @return bool
*/
function insert( $table, $a, $fname = 'DatabaseSqlite::insert', $options = array() ) {
if ( !count( $a ) ) {
@@ -610,14 +622,16 @@ class DatabaseSqlite extends DatabaseBase {
* @return string User-friendly database information
*/
public function getServerInfo() {
- return wfMsg( self::getFulltextSearchModule() ? 'sqlite-has-fts' : 'sqlite-no-fts', $this->getServerVersion() );
+ return wfMessage( self::getFulltextSearchModule() ? 'sqlite-has-fts' : 'sqlite-no-fts', $this->getServerVersion() )->text();
}
/**
* Get information about a given field
* Returns false if the field does not exist.
*
- * @return SQLiteField|false
+ * @param $table string
+ * @param $field string
+ * @return SQLiteField|bool False on failure
*/
function fieldInfo( $table, $field ) {
$tableName = $this->tableName( $table );
@@ -631,15 +645,15 @@ class DatabaseSqlite extends DatabaseBase {
return false;
}
- function begin( $fname = '' ) {
+ protected function doBegin( $fname = '' ) {
if ( $this->mTrxLevel == 1 ) {
- $this->commit();
+ $this->commit( __METHOD__ );
}
$this->mConn->beginTransaction();
$this->mTrxLevel = 1;
}
- function commit( $fname = '' ) {
+ protected function doCommit( $fname = '' ) {
if ( $this->mTrxLevel == 0 ) {
return;
}
@@ -647,7 +661,7 @@ class DatabaseSqlite extends DatabaseBase {
$this->mTrxLevel = 0;
}
- function rollback( $fname = '' ) {
+ protected function doRollback( $fname = '' ) {
if ( $this->mTrxLevel == 0 ) {
return;
}
@@ -656,15 +670,6 @@ class DatabaseSqlite extends DatabaseBase {
}
/**
- * @param $sql
- * @param $num
- * @return string
- */
- function limitResultForUpdate( $sql, $num ) {
- return $this->limitResult( $sql, $num );
- }
-
- /**
* @param $s string
* @return string
*/
@@ -723,6 +728,7 @@ class DatabaseSqlite extends DatabaseBase {
/**
* No-op version of deadlockLoop
+ * @return mixed
*/
public function deadlockLoop( /*...*/ ) {
$args = func_get_args();
@@ -812,12 +818,12 @@ class DatabaseSqlite extends DatabaseBase {
}
return $this->query( $sql, $fname );
}
-
-
+
+
/**
* List all tables on the database
*
- * @param $prefix Only show tables with this prefix, e.g. mw_
+ * @param $prefix string Only show tables with this prefix, e.g. mw_
* @param $fname String: calling function name
*
* @return array
@@ -828,21 +834,21 @@ class DatabaseSqlite extends DatabaseBase {
'name',
"type='table'"
);
-
+
$endArray = array();
-
- foreach( $result as $table ) {
+
+ foreach( $result as $table ) {
$vars = get_object_vars($table);
$table = array_pop( $vars );
-
+
if( !$prefix || strpos( $table, $prefix ) === 0 ) {
if ( strpos( $table, 'sqlite_' ) !== 0 ) {
$endArray[] = $table;
}
-
+
}
}
-
+
return $endArray;
}