Example #1
0
 /**
  * Build the CREATE TABLE query. Requires a table schema object.
  *
  * @param \Titon\Db\Query $query
  * @return string
  * @throws \Titon\Db\Exception\InvalidSchemaException
  */
 public function buildCreateTable(Query $query)
 {
     $schema = $query->getSchema();
     if (!$schema) {
         throw new InvalidSchemaException('Table creation requires a valid schema object');
     }
     return $this->renderStatement(Query::CREATE_TABLE, ['table' => $this->formatTable($schema->getTable()), 'columns' => $this->formatColumns($schema), 'keys' => $this->formatTableKeys($schema), 'options' => $this->formatTableOptions($schema->getOptions())] + $this->formatAttributes($query->getAttributes()));
 }