Jean-Lou Dupont wrote:
I used to do:
$db =& wfGetDB(DB_SLAVE);
$tbl = $db->tableName('interwiki');
$result = $db->query("SELECT iw_prefix,iw_url,iw_local,iw_trans
FROM $tbl");
while ( $row = mysql_fetch_array($result) )
$this->iwl[ $row[0] ] = array( 'uri' => $row[1],
'local' =>
$row[2],
'trans' =>
$row[3] );
$db->freeResult( $result );
in MW1.10 but now it seems this code does not work under MW1.11.
You're mixing abstraction levels, which leads to breakage when the
implementation changes.
mysql_fetch_array() requires a MySQL result resources as its parameter,
but $db->query() is not guaranteed to return one.
In recent versions of MediaWiki it returns a ResultWrapper instance,
which can be queried or iterated over as well as passed back to the
Database instance.
You can use $db->fetchRow( $result ) for better compatibility. (Most
MediaWiki code uses fetchObject() instead, but it doesn't really matter
which as long as you know what you're using.)
-- brion vibber (brion @
wikimedia.org)