Changeset 29664
- Timestamp:
- 09/02/2014 04:55:17 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/wp-db.php
r29165 r29664 1794 1794 } 1795 1795 1796 $wheres = empty( $where ) ? '' : ( ' WHERE ' . implode( ' AND ', $wheres ) ); 1797 1798 $sql = "UPDATE `$table` SET " . implode( ', ', $bits ) . $wheres; 1796 $sql = "UPDATE `$table` SET " . implode( ', ', $bits ) . ' WHERE ' . implode( ' AND ', $wheres ); 1799 1797 return $this->query( $this->prepare( $sql, array_merge( array_values( $data ), array_values( $where ) ) ) ); 1800 1798 } -
trunk/tests/phpunit/tests/db.php
r28814 r29664 439 439 440 440 /** 441 * wpdb::update() requires a WHERE condition. 441 442 * 442 443 * @ticket 26106 443 444 */ 444 function test_empty_where() { 445 global $wpdb; 445 function test_empty_where_on_update() { 446 global $wpdb; 447 $show = $wpdb->show_errors(false); 446 448 $wpdb->update( $wpdb->posts, array( 'post_name' => 'burrito' ), array() ); 447 449 448 $expected1 = "UPDATE `{$wpdb->posts}` SET `post_name` = 'burrito'"; 450 $expected1 = "UPDATE `{$wpdb->posts}` SET `post_name` = 'burrito' WHERE "; 451 $this->assertNotEmpty( $wpdb->last_error ); 449 452 $this->assertEquals( $expected1, $wpdb->last_query ); 450 453 … … 452 455 453 456 $expected2 = "UPDATE `{$wpdb->posts}` SET `post_name` = 'burrito' WHERE `post_status` = 'taco'"; 457 $this->assertEmpty( $wpdb->last_error ); 454 458 $this->assertEquals( $expected2, $wpdb->last_query ); 459 $wpdb->show_errors( $show ); 455 460 } 456 461 }
Note: See TracChangeset
for help on using the changeset viewer.