Index: trunk/phase3/includes/db/DatabaseMysql.php |
— | — | @@ -369,7 +369,7 @@ |
370 | 370 | * |
371 | 371 | * @return bool |
372 | 372 | */ |
373 | | - function insertOrUpdate( $table, $a, $fname = 'DatabaseBase::insertOnDupeUpdate', $options = array(), $onDupeUpdate = array() ) { |
| 373 | + function insertOrUpdate( $table, $a, $fname = 'DatabaseBase::insertOrUpdate', $options = array(), $onDupeUpdate = array() ) { |
374 | 374 | # No rows to insert, easy just return now |
375 | 375 | if ( !count( $a ) ) { |
376 | 376 | return true; |
Index: trunk/phase3/includes/db/Database.php |
— | — | @@ -1164,12 +1164,12 @@ |
1165 | 1165 | * @param $table String: table name (prefix auto-added) |
1166 | 1166 | * @param $a Array: Array of rows to insert |
1167 | 1167 | * @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) |
1169 | 1169 | * @param $onDupeUpdate Array: Associative array of fields to update on duplicate |
1170 | 1170 | * |
1171 | 1171 | * @return bool |
1172 | 1172 | */ |
1173 | | - function insertOrUpdate( $table, $a, $fname = 'DatabaseBase::insertOnDupeUpdate', $options = array(), $onDupeUpdate = array() ) { |
| 1173 | + function insertOrUpdate( $table, $a, $fname = 'DatabaseBase::insertOrUpdate', $options = array(), $onDupeUpdate = array() ) { |
1174 | 1174 | |
1175 | 1175 | if ( isset( $a[0] ) && is_array( $a[0] ) ) { |
1176 | 1176 | $keys = array_keys( $a[0] ); |
— | — | @@ -1183,21 +1183,21 @@ |
1184 | 1184 | $res = $this->select( |
1185 | 1185 | $table, |
1186 | 1186 | $keys, |
1187 | | - $this->makeList( $where, LIST_AND ), |
| 1187 | + $where, |
1188 | 1188 | __METHOD__ |
1189 | 1189 | ); |
1190 | 1190 | |
1191 | 1191 | 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] ) ) { |
1197 | 1197 | $options[$k] = str_replace( $k, $res[0]->{$k}, $onDupeUpdate[$k] ); |
1198 | 1198 | } |
1199 | 1199 | } |
1200 | 1200 | } else { |
1201 | | - //No results, it's just an insert |
| 1201 | + // No results, it's just an insert |
1202 | 1202 | $update = $where; |
1203 | 1203 | } |
1204 | 1204 | |