# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# http://www.gnu.org/copyleft/gpl.html
-
-# Simple generic object store
-# interface is intended to be more or less compatible with
-# the PHP memcached client.
-#
-# backends for local hash array and SQL table included:
-# $bag = new HashBagOStuff();
-# $bag = new MysqlBagOStuff($tablename); # connect to db first
-
-class /* abstract */ BagOStuff {
+/**
+ *
+ * @package MediaWiki
+ */
+
+/**
+ * Simple generic object store
+ *
+ * interface is intended to be more or less compatible with
+ * the PHP memcached client.
+ *
+ * backends for local hash array and SQL table included:
+ * $bag = new HashBagOStuff();
+ * $bag = new MysqlBagOStuff($tablename); # connect to db first
+ *
+ * @package MediaWiki
+ * @abstract
+ */
+class BagOStuff {
var $debugmode;
function BagOStuff() {
}
-/* Functional versions! */
+/**
+ * Functional versions!
+ * @todo document
+ * @package MediaWiki
+ */
class HashBagOStuff extends BagOStuff {
/*
This is a test of the interface, mainly. It stores
key (exptime)
);
*/
-class /* abstract */ SqlBagOStuff extends BagOStuff {
+
+/**
+ * @todo document
+ * @abstract
+ * @package MediaWiki
+ */
+class SqlBagOStuff extends BagOStuff {
var $table;
- function SqlBagOStuff($tablename = "objectcache") {
+
+ function SqlBagOStuff($tablename = 'objectcache') {
$this->table = $tablename;
}
$this->_debug("get: retrieved data; exp time is " . $row->exptime);
return unserialize($row->value);
} else {
- $this->_debug("get: no matching rows");
+ $this->_debug('get: no matching rows');
}
return false;
}
return true; /* ? */
}
+ function getTableName() {
+ return $this->table;
+ }
+
function _query($sql) {
$reps = func_get_args();
- $reps[0] = $this->table;
+ $reps[0] = $this->getTableName();
// ewwww
for($i=0;$i<count($reps);$i++) {
$sql = str_replace(
- "$" . $i,
+ '$' . $i,
$this->_strencode($reps[$i]),
$sql);
}
$res = $this->_doquery($sql);
if($res == false) {
- $this->_debug("query failed: " . $this->_dberror($res));
+ $this->_debug('query failed: ' . $this->_dberror($res));
}
return $res;
}
}
function _doquery($sql) {
- die( "abstract function SqlBagOStuff::_doquery() must be defined" );
+ die( 'abstract function SqlBagOStuff::_doquery() must be defined' );
}
function _fetchrow($res) {
- die( "abstract function SqlBagOStuff::_fetchrow() must be defined" );
+ die( 'abstract function SqlBagOStuff::_fetchrow() must be defined' );
}
function _freeresult($result) {
function _dberror($result) {
/* stub */
- return "unknown error";
+ return 'unknown error';
}
function _maxdatetime() {
- die( "abstract function SqlBagOStuff::_maxdatetime() must be defined" );
+ die( 'abstract function SqlBagOStuff::_maxdatetime() must be defined' );
}
function _fromunixtime() {
- die( "abstract function SqlBagOStuff::_fromunixtime() must be defined" );
+ die( 'abstract function SqlBagOStuff::_fromunixtime() must be defined' );
}
function expireall() {
}
}
+/**
+ * @todo document
+ * @package MediaWiki
+ */
class MediaWikiBagOStuff extends SqlBagOStuff {
+ var $tableInitialised = false;
+
function _doquery($sql) {
$dbw =& wfGetDB( DB_MASTER );
- return $dbw->query($sql, "MediaWikiBagOStuff:_doquery");
+ return $dbw->query($sql, 'MediaWikiBagOStuff:_doquery');
}
function _fetchobject($result) {
$dbw =& wfGetDB( DB_MASTER );
return $dbw->lastError();
}
function _maxdatetime() {
- return "9999-12-31 12:59:59";
+ return '9999-12-31 12:59:59';
}
function _fromunixtime($ts) {
- return gmdate( "Y-m-d H:i:s", $ts );
+ return gmdate( 'Y-m-d H:i:s', $ts );
}
function _strencode($s) {
$dbw =& wfGetDB( DB_MASTER );
return $dbw->strencode($s);
}
+ function getTableName() {
+ if ( !$this->tableInitialised ) {
+ $dbw =& wfGetDB( DB_MASTER );
+ $this->table = $dbw->tableName( $this->table );
+ $this->tableInitialised = true;
+ }
+ return $this->table;
+ }
}
+/**
+ * @todo document
+ * @package MediaWiki
+ */
class TurckBagOStuff extends BagOStuff {
function get($key) {
return mmcache_get( $key );