public function getAddTableDDL(Table $table) { $tableDescription = $table->hasDescription() ? $this->getCommentLineDDL($table->getDescription()) : ''; $lines = array(); foreach ($table->getColumns() as $column) { $lines[] = $this->getColumnDDL($column); } if ($table->hasPrimaryKey() && count($table->getPrimaryKey()) > 1) { $lines[] = $this->getPrimaryKeyDDL($table); } foreach ($table->getUnices() as $unique) { $lines[] = $this->getUniqueDDL($unique); } $sep = ",\n "; $pattern = "\n%sCREATE TABLE %s\n(\n %s\n);\n"; return sprintf($pattern, $tableDescription, $this->quoteIdentifier($table->getName()), implode($sep, $lines)); }
public function getAddTableDDL(Table $table) { $tableDescription = $table->hasDescription() ? $this->getCommentLineDDL($table->getDescription()) : ''; $lines = []; foreach ($table->getColumns() as $column) { $lines[] = $this->getColumnDDL($column); } foreach ($table->getUnices() as $unique) { $lines[] = $this->getUniqueDDL($unique); } $sep = ",\n "; $pattern = "\n%sCREATE TABLE %s\n(\n %s\n)%s;\n"; $ret = sprintf($pattern, $tableDescription, $this->quoteIdentifier($table->getName()), implode($sep, $lines), $this->generateBlockStorage($table)); $ret .= $this->getAddPrimaryKeyDDL($table); $ret .= $this->getAddSequencesDDL($table); return $ret; }
public function testSetDescription() { $table = new Table(); $this->assertFalse($table->hasDescription()); $table->setDescription('Some description'); $this->assertTrue($table->hasDescription()); $this->assertSame('Some description', $table->getDescription()); }