public function addTable(TableJoin $table) { if ($table->getIsRight()) { $this->rightTables[] = $table; } else { $this->leftTables[] = $table; } }
public function convertSqlToJob(SQLTokenIterator $tokens) { $tableJoin = new TableJoin(); $tableJoin->setDataSource($this->parseTableSource($tokens)); $joinJob = new Join(); $joinJob->addTable(clone $tableJoin); while (!is_null($joinData = $this->parseJoinOperator($tokens))) { $tableJoin->setDataSource($this->parseTableSource($tokens)); $tableJoin->setIsInner((bool) $joinData['isInner']); $tableJoin->setIsRight((bool) $joinData['isRight']); if ($tokens->seekTokenNum(SqlToken::T_ON())) { if (!$this->valueParser->canParseTokens($tokens)) { throw new MalformedSqlException("Missing valid condition after ON for JOIN!", $tokens); } $tableJoin->setCondition($this->valueParser->convertSqlToJob($tokens)); } elseif ($tokens->seekTokenNum(SqlToken::T_USING())) { if ($tokens->seekTokenText('(')) { throw new MalformedSqlException("Missing begin parenthesis after USING for JOIN!", $tokens); } if (!$this->columnParser->canParseTokens($tokens)) { throw new MalformedSqlException("Missing valid column specifier after USING for JOIN!", $tokens); } $tableJoin->setUsingColumnCondition($this->columnParser->convertSqlToJob($tokens)); if ($tokens->seekTokenText(')')) { throw new MalformedSqlException("Missing ending parenthesis after USING for JOIN!", $tokens); } } $joinJob->addTable(clone $tableJoin); } return $joinJob; }