Doctrine\ORM\Tools\SchemaTool::getCreateSchemaSql PHP Method

getCreateSchemaSql() public method

Gets the list of DDL statements that are required to create the database schema for the given list of ClassMetadata instances.
public getCreateSchemaSql ( array $classes ) : array
$classes array
return array $sql The SQL statements needed to create the schema for the classes.
    public function getCreateSchemaSql(array $classes)
    {
        $schema = $this->getSchemaFromMetadata($classes);
        return $schema->toSql($this->_platform);
    }

Usage Example

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     if ($this->option('sql')) {
         $this->info('Outputting create query:');
         $sql = $this->tool->getCreateSchemaSql($this->metadata->getAllMetadata());
         $this->info(implode(';' . PHP_EOL, $sql));
     } else {
         $this->info('Creating database schema...');
         $this->tool->createSchema($this->metadata->getAllMetadata());
         $this->info('Schema has been created!');
     }
 }
All Usage Examples Of Doctrine\ORM\Tools\SchemaTool::getCreateSchemaSql