public function joinWithPredicates($table, ...$predicates) { if (empty($predicates)) { throw new \RuntimeException('No predicates specified for join'); } $join = new JoinClause(); $join->setTableName($table); $join->setPredicates(WhereClause::buildPredicates($predicates, $table)); $this->addClause($join); return $this; }
public function assembleJoinClause(JoinClause $clause) { $segments = []; $source = $clause->getSource(); $destination = $clause->getDestination(); if ($source !== null && $destination !== null) { $segments[] = $this->assembleSegment($source) . ' = ' . $this->assembleSegment($destination); } if ($clause->hasPredicates()) { $segments = array_merge($segments, $this->assembleSegments($clause->getPredicates())); } return $clause->getAction() . ' ' . $this->assembleSegment($clause->getTable()) . ' ON ' . implode($clause->getGlue(), $segments); }