r71757 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71756‎ | r71757 | r71758 >
Date:22:23, 26 August 2010
Author:reedy
Status:reverted
Tags:
Comment:
Followup r71662

Update fname (same for DatabaseMysql)

Add missing spaces, remove superfluous makeList() call
Modified paths:
  • /trunk/phase3/includes/db/Database.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseMysql.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/DatabaseMysql.php
@@ -369,7 +369,7 @@
370370 *
371371 * @return bool
372372 */
373 - function insertOrUpdate( $table, $a, $fname = 'DatabaseBase::insertOnDupeUpdate', $options = array(), $onDupeUpdate = array() ) {
 373+ function insertOrUpdate( $table, $a, $fname = 'DatabaseBase::insertOrUpdate', $options = array(), $onDupeUpdate = array() ) {
374374 # No rows to insert, easy just return now
375375 if ( !count( $a ) ) {
376376 return true;
Index: trunk/phase3/includes/db/Database.php
@@ -1164,12 +1164,12 @@
11651165 * @param $table String: table name (prefix auto-added)
11661166 * @param $a Array: Array of rows to insert
11671167 * @param $fname String: Calling function name (use __METHOD__) for logs/profiling
1168 - * @param $options Mixed: Associative array of options (ignored)
 1168+ * @param $options Mixed: Associative array of options (ignored in this implementation)
11691169 * @param $onDupeUpdate Array: Associative array of fields to update on duplicate
11701170 *
11711171 * @return bool
11721172 */
1173 - function insertOrUpdate( $table, $a, $fname = 'DatabaseBase::insertOnDupeUpdate', $options = array(), $onDupeUpdate = array() ) {
 1173+ function insertOrUpdate( $table, $a, $fname = 'DatabaseBase::insertOrUpdate', $options = array(), $onDupeUpdate = array() ) {
11741174
11751175 if ( isset( $a[0] ) && is_array( $a[0] ) ) {
11761176 $keys = array_keys( $a[0] );
@@ -1183,21 +1183,21 @@
11841184 $res = $this->select(
11851185 $table,
11861186 $keys,
1187 - $this->makeList( $where, LIST_AND ),
 1187+ $where,
11881188 __METHOD__
11891189 );
11901190
11911191 if ( $res ) {
1192 - //Where there is a different value to set if this is being "updated", use the $onDupeUpdate value for that to
1193 - //replace the original option (if it was an insert), and replace the column name with the value read from
1194 - //the existing row
1195 - foreach( $where as $k => $v ){
1196 - if ( isset( $onDupeUpdate[$k] ) ){
 1192+ // Where there is a different value to set if this is being "updated", use the $onDupeUpdate value for that to
 1193+ // replace the original option (if it was an insert), and replace the column name with the value read from
 1194+ // the existing row
 1195+ foreach( $where as $k => $v ) {
 1196+ if ( isset( $onDupeUpdate[$k] ) ) {
11971197 $options[$k] = str_replace( $k, $res[0]->{$k}, $onDupeUpdate[$k] );
11981198 }
11991199 }
12001200 } else {
1201 - //No results, it's just an insert
 1201+ // No results, it's just an insert
12021202 $update = $where;
12031203 }
12041204

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r71662Fill out insertOrUpdate in DatabaseBase, rather than blank stub. Followup to ...reedy21:46, 25 August 2010

Status & tagging log