MediaWiki  REL1_24
DatabaseSqlite Class Reference
Inheritance diagram for DatabaseSqlite:
Collaboration diagram for DatabaseSqlite:

List of all members.

Public Member Functions

 __construct ($p=null)
 Constructor.
 addQuotes ($s)
 affectedRows ()
 attachDatabase ($name, $file=false, $fname=__METHOD__)
 Attaches external database to our connection, see http://sqlite.org/lang_attach.html for details.
 buildConcat ($stringList)
 Build a concatenation list to feed into a SQL query.
 buildGroupConcatField ($delim, $table, $field, $conds= '', $join_conds=array())
 Build a GROUP_CONCAT or equivalent statement for a query.
 buildLike ()
 checkForEnabledSearch ()
 Check if the searchindext table is FTS enabled.
 dataSeek ($res, $row)
 deadlockLoop ()
 No-op version of deadlockLoop.
 decodeBlob ($b)
 duplicateTableStructure ($oldName, $newName, $temporary=false, $fname=__METHOD__)
 encodeBlob ($b)
 fetchObject ($res)
 fetchRow ($res)
 fieldInfo ($table, $field)
 Get information about a given field Returns false if the field does not exist.
 fieldName ($res, $n)
 freeResult ($res)
 getSearchEngine ()
 getServerInfo ()
 getServerVersion ()
 getSoftwareLink ()
 getType ()
 implicitGroupby ()
 indexInfo ($table, $index, $fname=__METHOD__)
 Returns information about an index Returns false if the index does not exist.
 indexName ($index)
 Index names have DB scope.
 indexUnique ($table, $index, $fname=__METHOD__)
 insert ($table, $a, $fname=__METHOD__, $options=array())
 Based on generic method (parent) with some prior SQLite-sepcific adjustments.
 insertId ()
 This must be called after nextSequenceVal.
 isWriteQuery ($sql)
 lastErrno ()
 lastError ()
 listTables ($prefix=null, $fname=__METHOD__)
 List all tables on the database.
 lock ($lockName, $method, $timeout=5)
 Acquire a named lock.
 makeInsertOptions ($options)
 makeSelectOptions ($options)
 Filter the options used in SELECT statements.
 numFields ($res)
 numRows ($res)
 The PDO::Statement class implements the array interface so count() will work.
 open ($server, $user, $pass, $dbName)
 Open an SQLite database and return a resource handle to it NOTE: only $dbName is used, the other parameters are irrelevant for SQLite databases.
 openFile ($fileName)
 Opens a database file.
 replace ($table, $uniqueIndexes, $rows, $fname=__METHOD__)
 strencode ($s)
 tableName ($name, $format= 'quoted')
 Use MySQL's naming (accounts for prefix etc) but remove surrounding backticks.
 textFieldSize ($table, $field)
 Returns the size of a text field, or -1 for "unlimited" In SQLite this is SQLITE_MAX_LENGTH, by default 1GB.
 unionQueries ($sqls, $all)
 unionSupportsOrderAndLimit ()
 unlock ($lockName, $method)
 Release a lock.
 wasDeadlock ()
 wasErrorReissuable ()
 wasReadOnlyError ()

Static Public Member Functions

static fixIgnore ($options)
static generateFileName ($dir, $dbName)
 Generates a database file name.
static getFulltextSearchModule ()
 Returns version of currently supported SQLite fulltext search module or false if none present.

Public Attributes

string $mDatabaseFile
 File name for SQLite database file *.

Protected Member Functions

 closeConnection ()
 Does not actually close the connection, just destroys the reference for GC to do its work.
 doBegin ($fname= '')
 Issues the BEGIN command to the database server.
 doCommit ($fname= '')
 Issues the COMMIT command to the database server.
 doQuery ($sql)
 SQLite doesn't allow buffered results or data seeking etc, so we'll use fetchAll as the result.
 doRollback ($fname= '')
 Issues the ROLLBACK command to the database server.
 makeUpdateOptionsArray ($options)
 replaceVars ($s)

Protected Attributes

FSLockManager $lockMgr
 (hopefully on the same server as the DB) *
int $mAffectedRows
 The number of rows affected as an integer *.
PDO $mConn
 *
resource $mLastResult
 *

Static Private Attributes

static $fulltextEnabled = null

Detailed Description

Definition at line 28 of file DatabaseSqlite.php.


Constructor & Destructor Documentation

DatabaseSqlite::__construct ( params = null)

Constructor.

FIXME: It is possible to construct a Database object with no associated connection object, by specifying no parameters to __construct(). This feature is deprecated and should be removed.

DatabaseBase subclasses should not be constructed directly in external code. DatabaseBase::factory() should be used instead.

Parameters:
array$paramsParameters passed from DatabaseBase::factory()

Reimplemented from DatabaseBase.

Definition at line 42 of file DatabaseSqlite.php.

References array(), attachDatabase(), global, DatabaseBase\isOpen(), open(), and wfDeprecated().


Member Function Documentation

Parameters:
Blob | string$s
Returns:
string

Reimplemented from DatabaseBase.

Definition at line 773 of file DatabaseSqlite.php.

References $s.

Referenced by strencode().

Returns:
int

Implements DatabaseType.

Definition at line 447 of file DatabaseSqlite.php.

DatabaseSqlite::attachDatabase ( name,
file = false,
fname = __METHOD__ 
)

Attaches external database to our connection, see http://sqlite.org/lang_attach.html for details.

Parameters:
string$nameDatabase name to be used in queries like SELECT foo FROM dbname.table
bool | string$fileDatabase file name. If omitted, will be generated using $name and $wgSQLiteDataDir
string$fnameCalling function name
Returns:
ResultWrapper

Definition at line 225 of file DatabaseSqlite.php.

Referenced by __construct().

DatabaseSqlite::buildConcat ( stringList)

Build a concatenation list to feed into a SQL query.

Parameters:
string[]$stringList
Returns:
string

Reimplemented from DatabaseBase.

Definition at line 901 of file DatabaseSqlite.php.

DatabaseSqlite::buildGroupConcatField ( delim,
table,
field,
conds = '',
join_conds = array() 
)

Build a GROUP_CONCAT or equivalent statement for a query.

This is useful for combining a field for several rows into a single string. NULL values will not appear in the output, duplicated values will appear, and the resulting delimiter-separated values have no defined sort order. Code using the results may need to use the PHP unique() or sort() methods.

Parameters:
string$delimGlue to bind the results together
string | array$tableTable name
string$fieldField name
string | array$condsConditions
string | array$join_condsJoin conditions
Returns:
string SQL text
Since:
1.23

Reimplemented from DatabaseBase.

Definition at line 905 of file DatabaseSqlite.php.

Returns:
string

Reimplemented from DatabaseBase.

Definition at line 794 of file DatabaseSqlite.php.

Check if the searchindext table is FTS enabled.

Returns:
bool False if not enabled.

Definition at line 178 of file DatabaseSqlite.php.

References $fulltextEnabled, $res, DatabaseBase\query(), and tableName().

Does not actually close the connection, just destroys the reference for GC to do its work.

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 158 of file DatabaseSqlite.php.

DatabaseSqlite::dataSeek ( res,
row 
)
Parameters:
ResultWrapper | array$res
int$row

Implements DatabaseType.

Definition at line 405 of file DatabaseSqlite.php.

References $res.

No-op version of deadlockLoop.

Returns:
mixed

Reimplemented from DatabaseBase.

Definition at line 815 of file DatabaseSqlite.php.

Parameters:
Blob | string$b
Returns:
string

Reimplemented from DatabaseBase.

Definition at line 761 of file DatabaseSqlite.php.

DatabaseSqlite::doBegin ( fname = '') [protected]

Issues the BEGIN command to the database server.

See also:
DatabaseBase::begin()
Parameters:
string$fname

Reimplemented from DatabaseBase.

Definition at line 709 of file DatabaseSqlite.php.

DatabaseSqlite::doCommit ( fname = '') [protected]

Issues the COMMIT command to the database server.

See also:
DatabaseBase::commit()
Parameters:
string$fname

Reimplemented from DatabaseBase.

Definition at line 721 of file DatabaseSqlite.php.

DatabaseSqlite::doQuery ( sql) [protected]

SQLite doesn't allow buffered results or data seeking etc, so we'll use fetchAll as the result.

Parameters:
string$sql
Returns:
bool|ResultWrapper

Reimplemented from DatabaseBase.

Definition at line 251 of file DatabaseSqlite.php.

DatabaseSqlite::doRollback ( fname = '') [protected]

Issues the ROLLBACK command to the database server.

See also:
DatabaseBase::rollback()
Parameters:
string$fname

Reimplemented from DatabaseBase.

Definition at line 733 of file DatabaseSqlite.php.

DatabaseSqlite::duplicateTableStructure ( oldName,
newName,
temporary = false,
fname = __METHOD__ 
)
Exceptions:
MWException
Parameters:
string$oldName
string$newName
bool$temporary
string$fname
Returns:
bool|ResultWrapper

Reimplemented from DatabaseBase.

Definition at line 921 of file DatabaseSqlite.php.

Parameters:
string$b
Returns:
Blob

Reimplemented from DatabaseBase.

Definition at line 753 of file DatabaseSqlite.php.

Parameters:
ResultWrapper | array$res
Returns:
stdClass|bool

Implements DatabaseType.

Definition at line 279 of file DatabaseSqlite.php.

References $res, and as.

Parameters:
ResultWrapper | mixed$res
Returns:
array|bool

Implements DatabaseType.

Definition at line 306 of file DatabaseSqlite.php.

References $res.

DatabaseSqlite::fieldInfo ( table,
field 
)

Get information about a given field Returns false if the field does not exist.

Parameters:
string$table
string$field
Returns:
SQLiteField|bool False on failure

Implements DatabaseType.

Definition at line 696 of file DatabaseSqlite.php.

DatabaseSqlite::fieldName ( res,
n 
)
Parameters:
ResultWrapper$res
int$n
Returns:
bool

Implements DatabaseType.

Definition at line 354 of file DatabaseSqlite.php.

static DatabaseSqlite::fixIgnore ( options) [static]
Parameters:
array$options
Returns:
array

Definition at line 536 of file DatabaseSqlite.php.

References $options, and as.

Referenced by makeInsertOptions(), and makeUpdateOptionsArray().

Parameters:
ResultWrapper | mixed$res

Reimplemented from DatabaseBase.

Definition at line 267 of file DatabaseSqlite.php.

static DatabaseSqlite::generateFileName ( dir,
dbName 
) [static]

Generates a database file name.

Explicitly public for installer.

Parameters:
string$dirDirectory where database resides
string$dbNameDatabase name
Returns:
string

Definition at line 170 of file DatabaseSqlite.php.

Returns version of currently supported SQLite fulltext search module or false if none present.

Returns:
string

Definition at line 196 of file DatabaseSqlite.php.

Referenced by RebuildTextIndex\execute(), and SqliteUpdater\sqliteSetupSearchindex().

Returns:
string

Reimplemented from DatabaseBase.

Definition at line 806 of file DatabaseSqlite.php.

Returns:
string User-friendly database information

Reimplemented from DatabaseBase.

Definition at line 682 of file DatabaseSqlite.php.

Returns:
string Version information from the database

Implements DatabaseType.

Definition at line 673 of file DatabaseSqlite.php.

Returns:
string Wikitext of a link to the server software's web site

Implements DatabaseType.

Definition at line 666 of file DatabaseSqlite.php.

Returns:
string

Implements DatabaseType.

Definition at line 76 of file DatabaseSqlite.php.

Todo:
Check if it should be true like parent class
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 85 of file DatabaseSqlite.php.

DatabaseSqlite::indexInfo ( table,
index,
fname = __METHOD__ 
)

Returns information about an index Returns false if the index does not exist.

  • if errors are explicitly ignored, returns NULL on failure
Parameters:
string$table
string$index
string$fname
Returns:
array

Implements DatabaseType.

Definition at line 461 of file DatabaseSqlite.php.

Index names have DB scope.

Parameters:
string$index
Returns:
string

Reimplemented from DatabaseBase.

Definition at line 387 of file DatabaseSqlite.php.

DatabaseSqlite::indexUnique ( table,
index,
fname = __METHOD__ 
)
Parameters:
string$table
string$index
string$fname
Returns:
bool|null

Definition at line 484 of file DatabaseSqlite.php.

DatabaseSqlite::insert ( table,
a,
fname = __METHOD__,
options = array() 
)

Based on generic method (parent) with some prior SQLite-sepcific adjustments.

Parameters:
string$table
array$a
string$fname
array$options
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 565 of file DatabaseSqlite.php.

This must be called after nextSequenceVal.

Returns:
int

Implements DatabaseType.

Definition at line 396 of file DatabaseSqlite.php.

See also:
DatabaseBase::isWriteQuery()
Parameters:
string$sql
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 241 of file DatabaseSqlite.php.

Returns:
string

Implements DatabaseType.

Definition at line 434 of file DatabaseSqlite.php.

Returns:
string

Implements DatabaseType.

Definition at line 422 of file DatabaseSqlite.php.

DatabaseSqlite::listTables ( prefix = null,
fname = __METHOD__ 
)

List all tables on the database.

Parameters:
string$prefixOnly show tables with this prefix, e.g. mw_
string$fnameCalling function name
Returns:
array

Reimplemented from DatabaseBase.

Definition at line 954 of file DatabaseSqlite.php.

Referenced by DatabaseSqliteTest\getTables().

DatabaseSqlite::lock ( lockName,
method,
timeout = 5 
)

Acquire a named lock.

Abstracted from Filestore::lock() so child classes can implement for their own needs.

Parameters:
string$lockNameName of lock to aquire
string$methodName of method calling us
int$timeout
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 879 of file DatabaseSqlite.php.

Parameters:
array$options
Returns:
string

Reimplemented from DatabaseBase.

Definition at line 551 of file DatabaseSqlite.php.

References $options, and fixIgnore().

Filter the options used in SELECT statements.

Parameters:
array$options
Returns:
array

Reimplemented from DatabaseBase.

Definition at line 511 of file DatabaseSqlite.php.

DatabaseSqlite::makeUpdateOptionsArray ( options) [protected]
Parameters:
array$options
Returns:
string

Reimplemented from DatabaseBase.

Definition at line 525 of file DatabaseSqlite.php.

References $options, and fixIgnore().

Parameters:
ResultWrapper$res
Returns:
int

Implements DatabaseType.

Definition at line 338 of file DatabaseSqlite.php.

References $res.

The PDO::Statement class implements the array interface so count() will work.

Parameters:
ResultWrapper | array$res
Returns:
int

Implements DatabaseType.

Definition at line 328 of file DatabaseSqlite.php.

DatabaseSqlite::open ( server,
user,
pass,
dbName 
)

Open an SQLite database and return a resource handle to it NOTE: only $dbName is used, the other parameters are irrelevant for SQLite databases.

Parameters:
string$server
string$user
string$pass
string$dbName
Exceptions:
DBConnectionError
Returns:
PDO

Implements DatabaseType.

Definition at line 100 of file DatabaseSqlite.php.

Referenced by __construct().

DatabaseSqlite::openFile ( fileName)

Opens a database file.

Parameters:
string$fileName
Exceptions:
DBConnectionError
Returns:
PDO|bool SQL connection or false if failed

Definition at line 121 of file DatabaseSqlite.php.

DatabaseSqlite::replace ( table,
uniqueIndexes,
rows,
fname = __METHOD__ 
)
Parameters:
string$table
array$uniqueIndexesUnused
string | array$rows
string$fname
Returns:
bool|ResultWrapper

Reimplemented from DatabaseBase.

Definition at line 592 of file DatabaseSqlite.php.

DatabaseSqlite::replaceVars ( s) [protected]
Parameters:
string$s
Returns:
string

Reimplemented from DatabaseBase.

Reimplemented in MockDatabaseSqlite.

Definition at line 826 of file DatabaseSqlite.php.

References $s.

Parameters:
string$s
Returns:
string

Implements DatabaseType.

Definition at line 745 of file DatabaseSqlite.php.

References $s, and addQuotes().

DatabaseSqlite::tableName ( name,
format = 'quoted' 
)

Use MySQL's naming (accounts for prefix etc) but remove surrounding backticks.

Parameters:
string$name
string$format
Returns:
string

Reimplemented from DatabaseBase.

Definition at line 372 of file DatabaseSqlite.php.

Referenced by checkForEnabledSearch().

DatabaseSqlite::textFieldSize ( table,
field 
)

Returns the size of a text field, or -1 for "unlimited" In SQLite this is SQLITE_MAX_LENGTH, by default 1GB.

No way to query it though.

Parameters:
string$table
string$field
Returns:
int

Reimplemented from DatabaseBase.

Definition at line 620 of file DatabaseSqlite.php.

DatabaseSqlite::unionQueries ( sqls,
all 
)
Parameters:
string$sqls
bool$allWhether to "UNION ALL" or not
Returns:
string

Reimplemented from DatabaseBase.

Definition at line 636 of file DatabaseSqlite.php.

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 627 of file DatabaseSqlite.php.

DatabaseSqlite::unlock ( lockName,
method 
)

Release a lock.

Parameters:
string$lockNameName of lock to release
string$methodName of method calling us
Returns:
int Returns 1 if the lock was released, 0 if the lock was not established by this thread (in which case the lock is not released), and NULL if the named lock did not exist

Reimplemented from DatabaseBase.

Definition at line 891 of file DatabaseSqlite.php.

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 645 of file DatabaseSqlite.php.

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 652 of file DatabaseSqlite.php.

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 659 of file DatabaseSqlite.php.


Member Data Documentation

DatabaseSqlite::$fulltextEnabled = null [static, private]

Definition at line 30 of file DatabaseSqlite.php.

Referenced by checkForEnabledSearch().

FSLockManager DatabaseSqlite::$lockMgr [protected]

(hopefully on the same server as the DB) *

Definition at line 40 of file DatabaseSqlite.php.

int DatabaseSqlite::$mAffectedRows [protected]

The number of rows affected as an integer *.

Definition at line 34 of file DatabaseSqlite.php.

PDO DatabaseSqlite::$mConn [protected]

*

Reimplemented from DatabaseBase.

Definition at line 38 of file DatabaseSqlite.php.

string DatabaseSqlite::$mDatabaseFile

File name for SQLite database file *.

Definition at line 32 of file DatabaseSqlite.php.

resource DatabaseSqlite::$mLastResult [protected]

*

Definition at line 36 of file DatabaseSqlite.php.


The documentation for this class was generated from the following file: