2009/11/26 Tim Starling <tstarling(a)wikimedia.org>rg>:
Don't use subselects, they're not supported by
MySQL 4.0 which is what
we target.
$dbr = wfGetDB( DB_SLAVE );
$max = $dbr->selectField(
'recentchanges',
'max(rc_id)',
false,
__METHOD__,
array( 'GROUP BY' => 'rc_title' );
$res = $dbr->select(
'recentchanges',
'*',
array(
'rc_id' => $max,
'rc_namespace' => 0,
'rc_title' => 'Wiki',
),
__METHOD__ );
Note that the GROUP BY condition in the first query is unnecessary,
and that the whole thing could be rewritten to SELECT * FROM
recentchanges WHERE rc_namespace=0 AND rc_title='Wiki' ORDER BY rc_id
DESC LIMIT 1;
Roan Kattouw (Catrope)