Ejemplo n.º 1
0
 /**
  * Return DDL for table creation.
  *
  * @param string $dbType Database type (MYSQL, ORACLE or MSSQL).
  *
  * @return array|string
  */
 public function getCreateDdl($dbType = '')
 {
     $result = array();
     $items = array();
     /** @var Column $column */
     foreach ($this->columns->getList() as $column) {
         $items[] = $column->name . " " . $column->body;
     }
     if ($dbType !== 'MSSQL') {
         /** @var Constraint $constraint */
         foreach ($this->constraints->getList() as $constraint) {
             if ($constraint->name === '') {
                 $items[] = $constraint->body;
             } else {
                 $items[] = "CONSTRAINT " . $constraint->name . " " . $constraint->body;
             }
         }
     }
     $result[] = "CREATE TABLE " . $this->name . "(\n\t" . implode(",\n\t", $items) . "\n)" . $this->body;
     if ($dbType === 'MSSQL') {
         /** @var Constraint $constraint */
         foreach ($this->constraints->getList() as $constraint) {
             $result[] = $constraint->getCreateDdl($dbType);
         }
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * Return DDL for table creation.
  *
  * @param string $dbType Database type (MYSQL, ORACLE or MSSQL).
  *
  * @return array|string
  */
 public function getCreateDdl($dbType = '')
 {
     $items = array();
     /** @var Column $column */
     foreach ($this->columns->getList() as $column) {
         $items[] = $column->name . " " . $column->body;
     }
     /** @var Constraint $constraint */
     foreach ($this->constraints->getList() as $constraint) {
         $items[] = "CONSTRAINT " . $constraint->name . " " . $constraint->body;
     }
     return "CREATE TABLE " . $this->name . "(\n\t" . implode(",\n\t", $items) . "\n)" . $this->body;
 }
Ejemplo n.º 3
0
 /**
  * @param Tokenizer $tokenizer Statement tokens.
  *
  * @return void
  * @throws NotSupportedException
  */
 protected function executeCreateSequence(Tokenizer $tokenizer)
 {
     $tokenizer->skipWhiteSpace();
     $this->sequences->add(Sequence::create($tokenizer));
 }