r112953 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112952‎ | r112953 | r112954 >
Date:17:33, 3 March 2012
Author:ialex
Status:ok
Tags:
Comment:
Change some DatabaseBase::query() calls to use more specific methods
Modified paths:
  • /trunk/phase3/includes/ViewCountUpdate.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ViewCountUpdate.php
@@ -48,8 +48,7 @@
4949 $dbw = wfGetDB( DB_MASTER );
5050
5151 if ( $wgHitcounterUpdateFreq <= 1 || $dbw->getType() == 'sqlite' ) {
52 - $pageTable = $dbw->tableName( 'page' );
53 - $dbw->query( "UPDATE $pageTable SET page_counter = page_counter + 1 WHERE page_id = {$this->id}" );
 52+ $dbw->update( 'page', array( 'page_counter = page_counter + 1' ), array( 'page_id' => $this->id ), __METHOD__ );
5453 return;
5554 }
5655
@@ -71,10 +70,7 @@
7271
7372 $dbw = wfGetDB( DB_MASTER );
7473
75 - $hitcounterTable = $dbw->tableName( 'hitcounter' );
76 - $res = $dbw->query( "SELECT COUNT(*) as n FROM $hitcounterTable" );
77 - $row = $dbw->fetchObject( $res );
78 - $rown = intval( $row->n );
 74+ $rown = $dbw->selectField( 'hitcounter', 'COUNT(*)', array(), __METHOD__ );
7975
8076 if ( $rown < $wgHitcounterUpdateFreq ) {
8177 return;
@@ -87,6 +83,7 @@
8884
8985 $dbType = $dbw->getType();
9086 $tabletype = $dbType == 'mysql' ? "ENGINE=HEAP " : '';
 87+ $hitcounterTable = $dbw->tableName( 'hitcounter' );
9188 $acchitsTable = $dbw->tableName( 'acchits' );
9289 $pageTable = $dbw->tableName( 'page' );
9390

Status & tagging log