function UpdateComplexTest::testOrConditionUpdate in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Database/UpdateComplexTest.php \Drupal\system\Tests\Database\UpdateComplexTest::testOrConditionUpdate()
Tests updates with OR conditionals.
File
- core/
modules/ system/ src/ Tests/ Database/ UpdateComplexTest.php, line 20 - Contains \Drupal\system\Tests\Database\UpdateComplexTest.
Class
- UpdateComplexTest
- Tests the Update query builder, complex queries.
Namespace
Drupal\system\Tests\DatabaseCode
function testOrConditionUpdate() {
$update = db_update('test')
->fields(array(
'job' => 'Musician',
))
->condition(db_or()
->condition('name', 'John')
->condition('name', 'Paul'));
$num_updated = $update
->execute();
$this
->assertIdentical($num_updated, 2, 'Updated 2 records.');
$num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(
':job' => 'Musician',
))
->fetchField();
$this
->assertIdentical($num_matches, '2', 'Updated fields successfully.');
}