Difference between revisions of "Extension:MediaWikiLite.php"
(make a start) |
(open()) |
||
Line 5: | Line 5: | ||
if (!defined('MEDIAWIKI')) die('Not an entry point.'); | if (!defined('MEDIAWIKI')) die('Not an entry point.'); | ||
+ | if (!defined('SQLITE_OK')) die('SQLite is not installed!'); | ||
define('SQLITE_VERSION','0.0.0, 2007-12-17'); | define('SQLITE_VERSION','0.0.0, 2007-12-17'); | ||
− | $wgDBtype = 'sqlite'; | + | $wgDBtype = 'sqlite'; |
+ | $wgSQLiteDataDir = dirname(__FILE__); | ||
$wgExtensionCredits['other'][] = array( | $wgExtensionCredits['other'][] = array( | ||
Line 43: | Line 45: | ||
} | } | ||
− | + | # Open an SQLite database and return a resource handle to it | |
− | + | # NOTE: only $dbName is used, the other parameters are irrelevant for SQLite databases | |
− | + | function open($server,$user,$password,$dbName) { | |
− | + | global $wgSQLiteDataDir; | |
− | function open( $server, $user, $password, $dbName ) { | + | $this->mConn = false; |
+ | if ($this->mFlags & DBO_PERSISTENT) @$this->mConn = sqlite_popen("$wgSQLiteDataDir/$dbName',0666,$err); | ||
+ | else @$this->mConn = @$this->mConn = sqlite_open("$wgSQLiteDataDir/$dbName',0666,$err); | ||
+ | if ($this->mConn === false) wfDebug("DB connection error: $err\n");; | ||
+ | $this->mOpened = $this->mConn; | ||
+ | return $this->mConn; | ||
} | } | ||
} | } |
Revision as of 05:34, 30 December 2007
<?php
- Extension:SQLite
Template:PhpCategory:Extensions in progress
- - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
- - Author: User:NadCategory:Extensions created with Template:Extension
if (!defined('MEDIAWIKI')) die('Not an entry point.'); if (!defined('SQLITE_OK')) die('SQLite is not installed!');
define('SQLITE_VERSION','0.0.0, 2007-12-17');
$wgDBtype = 'sqlite'; $wgSQLiteDataDir = dirname(__FILE__);
$wgExtensionCredits['other'][] = array( 'name' => 'SQLite', 'author' => 'User:Nad', 'description' => 'Allow MediaWiki installations to store content in an SQLite database instead of MySQL', 'url' => 'http://www.organicdesign.co.nz/Extension:SQLite.php', 'version' => SQLITE_VERSION );
class DatabaseSqlite extends Database {
function DatabaseSqlite($server = false, $user = false, $password = false, $dbName = false, $failFunction = false, $flags = 0) { global $wgOut; # Can't get a reference if it hasn't been set yet if (!isset($wgOut)) $wgOut = NULL; $this->mOut =& $wgOut; $this->mFailFunction = $failFunction; $this->mFlags = $flags; $this->open($server, $user, $password, $dbName); }
function cascadingDeletes() { return true; } function cleanupTriggers() { return true; } function strictIPs() { return true; } function realTimestamps() { return true; } function implicitGroupby() { return false; } function implicitOrderby() { return false; } function searchableIPs() { return true; } function functionalIndexes() { return true; }
static function newFromParams($server, $user, $password, $dbName, $failFunction = false, $flags = 0) { return new DatabaseSqlite($server, $user, $password, $dbName, $failFunction, $flags); }
# Open an SQLite database and return a resource handle to it # NOTE: only $dbName is used, the other parameters are irrelevant for SQLite databases function open($server,$user,$password,$dbName) { global $wgSQLiteDataDir; $this->mConn = false; if ($this->mFlags & DBO_PERSISTENT) @$this->mConn = sqlite_popen("$wgSQLiteDataDir/$dbName',0666,$err); else @$this->mConn = @$this->mConn = sqlite_open("$wgSQLiteDataDir/$dbName',0666,$err); if ($this->mConn === false) wfDebug("DB connection error: $err\n");; $this->mOpened = $this->mConn; return $this->mConn; }
}