public function createTable(Table $table) { $columns = array(); $name = $table->getName(); foreach ($table->getColumns() as $column) { $columns[] = $this->getColumnSpecification($column); } if ($pk = $table->getPrimaryKey()) { $columns[] = "PRIMARY KEY (\"{$pk}\")"; } $columns = implode(',', $columns); return "CREATE TABLE \"{$name}\" ({$columns})"; }
public function getReferentColumn(Table $table) { if (!$this->column instanceof Column) { list(, $column) = explode('.', $this->column); $this->column = $table->getCorrespondingColumn($column); } return $this->column; }
private function getJoinCondition(Table $a, Table $b) { $crit = array(); foreach ($b->getForeignKeys() as $fk) { $col = $fk->getReferentColumn($a); if ($col) { $crit[] = $col->eq($fk->getParent()); } } if ($a != $b) { foreach ($a->getForeignKeys() as $fk) { $col = $fk->getReferentColumn($b); if ($col) { $crit[] = $col->eq($fk->getParent()); } } } if (count($crit) == 0) { throw new JoinConditionError("Can't find any foreign key relationships " . "between '" . $a->getName() . "' and '" . $b->getName() . "'"); } elseif (count($crit) > 1) { return new ExpressionList($crit); } return $crit[0]; }
protected function visitTable(Table $table) { return $this->preparer->formatTable($table->getName()); }