r77405 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77404‎ | r77405 | r77406 >
Date:22:29, 28 November 2010
Author:yaron
Status:resolved (Comments)
Tags:
Comment:
Improved SQL querying calls
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_Utils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_Utils.php
@@ -200,11 +200,12 @@
201201 */
202202 static function getAllForms() {
203203 $dbr = wfGetDB( DB_SLAVE );
204 - $query = "SELECT page_title FROM " . $dbr->tableName( 'page' ) .
205 - " WHERE page_namespace = " . SF_NS_FORM .
206 - " AND page_is_redirect = 0" .
207 - " ORDER BY page_title";
208 - $res = $dbr->query( $query );
 204+ $res = $dbr->select( $dbr->tableNames( 'page' ),
 205+ 'page_title',
 206+ array( 'page_namespace' => SF_NS_FORM,
 207+ 'page_is_redirect' => false ),
 208+ __METHOD__,
 209+ array( 'ORDER BY' => 'page_title' ) );
209210 $form_names = array();
210211 while ( $row = $dbr->fetchRow( $res ) ) {
211212 $form_names[] = str_replace( '_', ' ', $row[0] );
@@ -372,10 +373,10 @@
373374 $substring = str_replace( "'", "\'", $substring );
374375 $conditions .= " AND (LOWER(CONVERT(`page_title` USING utf8)) LIKE '$substring%' OR LOWER(CONVERT(`page_title` USING utf8)) LIKE '%\_$substring%')";
375376 }
376 - $sql_options['ORDER BY'] = 'page_title';
377377 $res = $db->select( $db->tableNames( 'page' ),
378378 'page_title',
379 - $conditions, __METHOD__, $sql_options );
 379+ $conditions, __METHOD__,
 380+ array( 'ORDER BY' => 'page_title' ) );
380381 while ( $row = $db->fetchRow( $res ) ) {
381382 $cur_value = str_replace( '_', ' ', $row[0] );
382383 if ( $substring == null ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r77431Follow-up to r77405 , based on Code Review - removed extraneous calls to Data...yaron19:53, 29 November 2010

Comments

#Comment by MaxSem (talk | contribs)   19:05, 29 November 2010

select() calls tableName() automatically, you're adding the DB prefix twice.

#Comment by Yaron Koren (talk | contribs)   19:54, 29 November 2010

Thanks; this is fixed now.

Status & tagging log