Changeset 28814
- Timestamp:
- 06/24/2014 12:23:09 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/wp-db.php
r28711 r28814 1786 1786 } 1787 1787 1788 $sql = "UPDATE `$table` SET " . implode( ', ', $bits ) . ' WHERE ' . implode( ' AND ', $wheres ); 1788 $wheres = empty( $where ) ? '' : ( ' WHERE ' . implode( ' AND ', $wheres ) ); 1789 1790 $sql = "UPDATE `$table` SET " . implode( ', ', $bits ) . $wheres; 1789 1791 return $this->query( $this->prepare( $sql, array_merge( array_values( $data ), array_values( $where ) ) ) ); 1790 1792 } -
trunk/tests/phpunit/tests/db.php
r28711 r28814 437 437 $this->assertEquals( 'Walter Replace Sobchak', $row->display_name ); 438 438 } 439 440 /** 441 * 442 * @ticket 26106 443 */ 444 function test_empty_where() { 445 global $wpdb; 446 $wpdb->update( $wpdb->posts, array( 'post_name' => 'burrito' ), array() ); 447 448 $expected1 = "UPDATE `{$wpdb->posts}` SET `post_name` = 'burrito'"; 449 $this->assertEquals( $expected1, $wpdb->last_query ); 450 451 $wpdb->update( $wpdb->posts, array( 'post_name' => 'burrito' ), array( 'post_status' => 'taco' ) ); 452 453 $expected2 = "UPDATE `{$wpdb->posts}` SET `post_name` = 'burrito' WHERE `post_status` = 'taco'"; 454 $this->assertEquals( $expected2, $wpdb->last_query ); 455 } 439 456 }
Note: See TracChangeset
for help on using the changeset viewer.