function SelectComplexTest::testJoinTwice in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Database/SelectComplexTest.php \Drupal\system\Tests\Database\SelectComplexTest::testJoinTwice()
Confirms we can join on a single table twice with a dynamic alias.
File
- core/
modules/ system/ src/ Tests/ Database/ SelectComplexTest.php, line 314 - Contains \Drupal\system\Tests\Database\SelectComplexTest.
Class
- SelectComplexTest
- Tests the Select query builder with more complex queries.
Namespace
Drupal\system\Tests\DatabaseCode
function testJoinTwice() {
$query = db_select('test')
->fields('test');
$alias = $query
->join('test', 'test', 'test.job = %alias.job');
$query
->addField($alias, 'name', 'othername');
$query
->addField($alias, 'job', 'otherjob');
$query
->where("{$alias}.name <> test.name");
$crowded_job = $query
->execute()
->fetch();
$this
->assertEqual($crowded_job->job, $crowded_job->otherjob, 'Correctly joined same table twice.');
$this
->assertNotEqual($crowded_job->name, $crowded_job->othername, 'Correctly joined same table twice.');
}