function UpdateTest::testWhereAndConditionUpdate
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Database/UpdateTest.php \Drupal\KernelTests\Core\Database\UpdateTest::testWhereAndConditionUpdate()
- 8.9.x core/tests/Drupal/KernelTests/Core/Database/UpdateTest.php \Drupal\KernelTests\Core\Database\UpdateTest::testWhereAndConditionUpdate()
- 10 core/tests/Drupal/KernelTests/Core/Database/UpdateTest.php \Drupal\KernelTests\Core\Database\UpdateTest::testWhereAndConditionUpdate()
Confirms that we can stack condition and where calls.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ UpdateTest.php, line 91
Class
- UpdateTest
- Tests the update query builder.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testWhereAndConditionUpdate() : void {
$update = $this->connection
->update('test')
->fields([
'job' => 'Musician',
])
->where('[age] > :age', [
':age' => 26,
])
->condition('name', 'Ringo');
$num_updated = $update->execute();
$this->assertSame(1, $num_updated, 'Updated 1 record.');
$num_matches = $this->connection
->query('SELECT COUNT(*) FROM {test} WHERE [job] = :job', [
':job' => 'Musician',
])
->fetchField();
$this->assertSame('1', $num_matches, 'Updated fields successfully.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.