wiki.techinc.nl/includes/SiteStatsUpdate.php
Tim Starling ac549401d4 * Support for table name prefixes throughout the code. No support yet for converting static SQL, which also means no installation. But it has been tested by creating the tables in the ordinary way and then renaming them
* DB_WRITE now called DB_MASTER, DB_READ now called DB_SLAVE
* Converted to use SQL wrapper functions instead of direct SQL in various places
* Experimental method for preserving the chronological order of events when slave servers are used. Untested.
* Fixes to the new post-parse existence test feature
* Some.. other stuff
2004-07-18 08:48:43 +00:00

45 lines
1 KiB
PHP

<?php
# $Id$
# See deferred.doc
class SiteStatsUpdate {
var $mViews, $mEdits, $mGood;
function SiteStatsUpdate( $views, $edits, $good )
{
$this->mViews = $views;
$this->mEdits = $edits;
$this->mGood = $good;
}
function doUpdate()
{
$a = array();
if ( $this->mViews < 0 ) { $m = "-1"; }
else if ( $this->mViews > 0 ) { $m = "+1"; }
else $m = "";
array_push( $a, "ss_total_views=(ss_total_views$m)" );
if ( $this->mEdits < 0 ) { $m = "-1"; }
else if ( $this->mEdits > 0 ) { $m = "+1"; }
else $m = "";
array_push( $a, "ss_total_edits=(ss_total_edits$m)" );
if ( $this->mGood < 0 ) { $m = "-1"; }
else if ( $this->mGood > 0 ) { $m = "+1"; }
else $m = "";
array_push( $a, "ss_good_articles=(ss_good_articles$m)" );
$db =& wfGetDB( DB_MASTER );
$site_stats = $db->tableName( 'site_stats' );
$lowpri = $db->lowPriorityOption();
$sql = "UPDATE $lowpri $site_stats SET " . implode ( ",", $a ) .
" WHERE ss_row_id=1";
$db->query( $sql, "SiteStatsUpdate::doUpdate" );
}
}
?>