/** * Tests the \Joomla\Database\DatabaseQuery::join method. * * @return void * * @covers \Joomla\Database\DatabaseQuery::join * @since 1.0 */ public function testJoin() { $this->assertThat($this->instance->join('INNER', 'foo ON foo.id = bar.id'), $this->identicalTo($this->instance), 'Tests chaining.'); $join = TestHelper::getValue($this->instance, 'join'); $this->assertThat(trim($join[0]), $this->equalTo('INNER JOIN foo ON foo.id = bar.id'), 'Tests that first join renders correctly.'); $this->instance->join('OUTER', 'goo ON goo.id = car.id'); $join = TestHelper::getValue($this->instance, 'join'); $this->assertThat(trim($join[1]), $this->equalTo('OUTER JOIN goo ON goo.id = car.id'), 'Tests that second join renders correctly.'); }
/** * registerQueryTables * * @param DatabaseQuery $query * * @return DatabaseQuery */ public function registerQueryTables(DatabaseQuery $query) { foreach ($this->tables as $alias => $table) { if ($table['join'] == 'FROM') { $query->from($query->quoteName($table['name']) . ' AS ' . $query->quoteName($alias)); } else { $query->join($table['join'], $query->quoteName($table['name']) . ' AS ' . $query->quoteName($alias) . ' ' . $table['condition']); } } return $query; }