function SelectComplexTest::testJoinTwice
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php \Drupal\KernelTests\Core\Database\SelectComplexTest::testJoinTwice()
- 8.9.x core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php \Drupal\KernelTests\Core\Database\SelectComplexTest::testJoinTwice()
- 10 core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php \Drupal\KernelTests\Core\Database\SelectComplexTest::testJoinTwice()
Confirms we can join on a single table twice with a dynamic alias.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ SelectComplexTest.php, line 334
Class
- SelectComplexTest
- Tests the Select query builder with more complex queries.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testJoinTwice() : void {
$query = $this->connection
->select('test')
->fields('test');
$alias = $query->join('test', 'test', '[test].[job] = [%alias].[job]');
$query->addField($alias, 'name', 'other_name');
$query->addField($alias, 'job', 'other_job');
$query->where("[{$alias}].[name] <> [test].[name]");
$crowded_job = $query->execute()
->fetch();
$this->assertEquals($crowded_job->other_job, $crowded_job->job, 'Correctly joined same table twice.');
$this->assertNotEquals($crowded_job->other_name, $crowded_job->name, 'Correctly joined same table twice.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.