Difference between revisions of "Extension:MediaWikiLite.php"

From Organic Design wiki
m
(close())
Line 55: Line 55:
 
$this->mOpened = $this->mConn;
 
$this->mOpened = $this->mConn;
 
return $this->mConn;
 
return $this->mConn;
 +
}
 +
 +
# Close an SQLite database
 +
function close() {
 +
$this->mOpened = false;
 +
if ($this->mConn) {
 +
if ($this->trxLevel()) $this->immediateCommit();
 +
sqlite_close($this->mConn);
 +
}
 +
return true;
 
}
 
}
  
 
}
 
}

Revision as of 05:42, 30 December 2007

<?php

  1. Extension:SQLite
Info.svg These are the MediaWiki extensions we're using and/or developing. Please refer to the information on the mediawiki.org wiki for installation and usage details. Extensions here which have no corresponding mediawiki article are either not ready for use or have been superseded. You can also browse our extension code in our local Subversion repository or our GitHub mirror.

Template:PhpCategory:Extensions in progress

  1. - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
  2. - 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; }

# Close an SQLite database function close() { $this->mOpened = false; if ($this->mConn) { if ($this->trxLevel()) $this->immediateCommit(); sqlite_close($this->mConn); } return true; }

}