Extension:DataModel

Installation
To install this extension, add the following to LocalSettings.php:

Introduction
DataModel is nothing more than another layer shielding you from direct database access. It provides access to data in a database through in rather restrictive ways (see more below) in order to try to aid in scaling your data. It does so by:
 * revolving all data around a "shard key"
 * heavily rely on cache

Currently, no data is really being sharded. Once the required boilerplate code to allow to actually set up and connect to a sharded db structure, it should be possible to create a DataModelBackend though, which then actively distributes the data to multiple servers for real.

DataModel
DataModel.php can be easily extended (as sample/DataModelSample.php does) for a specific implementation. Basically, these methods can then be used to get/manipulate the data:

Public methods






->insert: Will insert the data of a newly created object (e.g. DataModelSample) into the DB (and temporarily cache)

->update: Will update altered data of an existing object in the DB (and cache)

->delete: Will delete DB & cache data

Static vars
static $table, $idColumn, $shardColumn: These static vars should be set in the extending class (e.g. sample/DataModelSample.php) for the DataModel code to know which value the key should be sharded over (or not - sharding is assumed), which table to write the data to and which unique id to save for the lists.

static $lists, $sorts (I promised to get back to this): Performing a selection query (e.g. "... WHERE visible = 1 ORDER BY title DESC") is quite a PITA when the data is possibly spread over multiple sharded DB's. Instead, a specific DataModel implementation (e.g. DataModelSample, which extends DataModel) should define "public static $lists = array(

Feedback
Open tickets in Wikimedia's Bugzilla under the "DataModel" component in the "MediaWiki extensions" product.
 * Open DataModel tickets