Difference between revisions of "Extension:MediaWikiLite.php"

From Organic Design wiki
m
m
 
(19 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<?php
+
{{legacy|this is now done using the built in [[SQLite]] database layer}}
# Extension:SQLite{{Category:Extensions|SQLite}}{{php}}{{Category:Extensions in progress|SQLite}}
+
<php><?php
 +
# Extension:MediaWikiLite
 
# - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
 
# - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
# - Author: [http://www.organicdesign.co.nz/nad User:Nad]{{Category:Extensions created with Template:Extension}}
+
# - Author: [http://www.organicdesign.co.nz/nad User:Nad]
 +
# - Started: 2007-12-17
  
 
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!');
+
if (!defined('PDO::ATTR_SERVER_VERSION')) die('PDO::SQLite3 is not installed!');
  
define('SQLITE_VERSION','0.0.0, 2007-12-17');
+
define('MWLITE_VERSION','0.1.0, 2008-01-16');
  
$wgDBtype       = 'sqlite';
+
$wgDBtype = 'sqlite';
 +
 
 +
# Currently all the data for each wiki is in its own file in $wgSQLiteDataDir
 
$wgSQLiteDataDir = dirname(__FILE__);
 
$wgSQLiteDataDir = dirname(__FILE__);
 +
 +
# For debugging
 +
$wgShowSQLErrors = true;
 +
$wgShowExceptionDetails = true;
 +
 +
# Ensure the LoadBalancer knows how to load our DB class when the time comes
 +
$wgAutoloadClasses['DatabaseSqlite'] = dirname(__FILE__)."/DatabaseSqlite.php";
  
 
$wgExtensionCredits['other'][] = array(
 
$wgExtensionCredits['other'][] = array(
'name'        => 'SQLite',
+
'name'        => 'MediaWikiLite',
 
'author'      => '[http://www.organicdesign.co.nz/nad User:Nad]',
 
'author'      => '[http://www.organicdesign.co.nz/nad User:Nad]',
'description' => 'Allow MediaWiki installations to store content in an [http://www.sqlite.org SQLite] database instead of MySQL',
+
'description' => 'Allow MediaWiki installations to store content in an [http://www.sqlite.org SQLite] database instead of MySQL, and to run as a daemon independently of a web-server.',
 
'url'        => 'http://www.organicdesign.co.nz/Extension:SQLite.php',
 
'url'        => 'http://www.organicdesign.co.nz/Extension:SQLite.php',
'version'    => SQLITE_VERSION
+
'version'    => MWLITE_VERSION
 
);
 
);
 
+
</php>
class DatabaseSqlite extends Database {
+
[[Category:Legacy Extensions|MediaWikiLite]]
 
 
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;
 
}
 
 
 
}
 

Latest revision as of 14:58, 22 October 2014

Legacy.svg Legacy: This article describes a concept that has been superseded in the course of ongoing development on the Organic Design wiki. Please do not develop this any further or base work on this concept, this is only useful for a historic record of work done. You may find a link to the currently used concept or function in this article, if not you can contact the author to find out what has taken the place of this legacy item.

Please refer to [[this is now done using the built in SQLite database layer]] instead.

<php><?php

  1. Extension:MediaWikiLite
  2. - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
  3. - Author: User:Nad
  4. - Started: 2007-12-17

if (!defined('MEDIAWIKI')) die('Not an entry point.'); if (!defined('PDO::ATTR_SERVER_VERSION')) die('PDO::SQLite3 is not installed!');

define('MWLITE_VERSION','0.1.0, 2008-01-16');

$wgDBtype = 'sqlite';

  1. Currently all the data for each wiki is in its own file in $wgSQLiteDataDir

$wgSQLiteDataDir = dirname(__FILE__);

  1. For debugging

$wgShowSQLErrors = true; $wgShowExceptionDetails = true;

  1. Ensure the LoadBalancer knows how to load our DB class when the time comes

$wgAutoloadClasses['DatabaseSqlite'] = dirname(__FILE__)."/DatabaseSqlite.php";

$wgExtensionCredits['other'][] = array( 'name' => 'MediaWikiLite', 'author' => 'User:Nad', 'description' => 'Allow MediaWiki installations to store content in an SQLite database instead of MySQL, and to run as a daemon independently of a web-server.', 'url' => 'http://www.organicdesign.co.nz/Extension:SQLite.php', 'version' => MWLITE_VERSION ); </php>