/** * @test */ public function itShouldWriteJoin() { $this->query->isJoin(true)->setTable('user')->on()->equals('user_id', 1); $expected = 'JOIN user ON (user.user_id = :v1)'; $this->assertSame($expected, $this->writer->write($this->query)); $expected = array(':v1' => 1); $this->assertEquals($expected, $this->writer->getValues()); }
/** * @param Select $select * @param string $selfColumn * @param string $refColumn * * @return Select */ public function addJoin(Select $select, $selfColumn, $refColumn) { $select->isJoin(true); $table = $select->getTable()->getName(); if (!isset($this->joins[$table])) { $newColumn = array($selfColumn); $select->joinCondition()->equals($refColumn, SyntaxFactory::createColumn($newColumn, $this->select->getTable())); $this->joins[$table] = $select; } return $this->joins[$table]; }