On 07/02/07, John Moorhouse <john.moorhouse(a)3jays.me.uk> wrote:
> $dbr =& wfGetDB( DB_SLAVE );
> $ts = mktime();
> $now = gmdate("YmdHis", $ts + 120);
> $ns = $wgTitle->getNamespace();
> $ti = $dbr->addQuotes($wgTitle->getDBkey());
> $sql = "UPDATE page SET page_touched='$now' WHERE page_namespace=$ns
AND page_title='$ti'";
> $res = $dbr->doQuery( $sql );
You shouldn't need to do a manual touch like this in newer versions of
MediaWiki; calling $parser->disableCache() ought to do the trick,
where $parser is an instance of the Parser object.
If, however, such an operation *is* needed, use something like:
$dbw = wfGetDB( DB_MASTER );
$dbw->update( 'page', array( 'page_touched' => gmdate(
'YmdHis',
gmtime() + 120 ) ), array( 'page_namespace' =>
$wgTitle->getNamespace(), 'page_title' => $wgTitle->getDBkey() ),
__METHOD__ );
Note that it is *not* a good idea to attempt to send write operations
to a slave database server in a true replication environment, and all
code should be written with this in mind; it doesn't make much
difference for single-server environments, but sticking to that makes
the code safer and more portable, and coupled with the convention of
using $dbr for slaves and $dbw for masters, makes it much more
readable and maintainable.
Rob Church