PHP Class Doctrine\ORM\Tools\SchemaTool

Since: 2.0
Author: Guilherme Blanco ([email protected])
Author: Jonathan Wage ([email protected])
Author: Roman Borschel ([email protected])
Author: Benjamin Eberlei ([email protected])
Author: Stefano Rodriguez ([email protected])
Show file Open project: pmjones/php-framework-benchmarks Class Usage Examples

Public Methods

Method Description
__construct ( EntityManager $em ) Initializes a new SchemaTool instance that uses the connection of the provided EntityManager.
createSchema ( array $classes ) Creates the database schema for the given array of ClassMetadata instances.
dropDatabase ( ) : void Drops all elements in the database of the current connection.
dropSchema ( array $classes ) : void Drops the database schema for the given classes.
getCreateSchemaSql ( array $classes ) : array Gets the list of DDL statements that are required to create the database schema for the given list of ClassMetadata instances.
getDropDatabaseSQL ( ) : array Gets the SQL needed to drop the database schema for the connections database.
getDropSchemaSQL ( array $classes ) : array
getSchemaFromMetadata ( array $classes ) : Schema From a given set of metadata classes this method creates a Schema instance.
getUpdateSchemaSql ( array $classes, $saveMode = false ) : array Gets the sequence of SQL statements that need to be performed in order to bring the given class mappings in-synch with the relational schema.
updateSchema ( array $classes, $saveMode = false ) : void Updates the database schema of the given classes by comparing the ClassMetadata ins$tableNametances to the current database schema that is inspected.

Private Methods

Method Description
_gatherColumn ( Doctrine\ORM\Mapping\ClassMetadata $class, array $mapping, Table $table ) : array Creates a column definition as required by the DBAL from an ORM field mapping definition.
_gatherColumns ( Doctrine\ORM\Mapping\ClassMetadata $class, Table $table ) : array Gathers the column definitions as required by the DBAL of all field mappings found in the given class.
_gatherRelationJoinColumns ( array $joinColumns, Doctrine\DBAL\Schema\Table $theJoinTable, Doctrine\ORM\Mapping\ClassMetadata $class, Doctrine\ORM\Mapping\AssociationMapping $mapping, array &$primaryKeyColumns, array &$uniqueConstraints ) Gather columns and fk constraints that are required for one part of relationship.
_gatherRelationsSql ( Doctrine\ORM\Mapping\ClassMetadata $class, Doctrine\DBAL\Schema\Table $table, Doctrine\DBAL\Schema\Schema $schema ) : void Gathers the SQL for properly setting up the relations of the given class.
_getAssociationTables ( array $classes )
_getCommitOrder ( array $classes )
_getDiscriminatorColumnDefinition ( Doctrine\ORM\Mapping\ClassMetadata $class, $table ) : array Gets a portable column definition as required by the DBAL for the discriminator column of a class.
processingNotRequired ( Doctrine\ORM\Mapping\ClassMetadata $class, array $processedClasses ) : boolean Some instances of ClassMetadata don't need to be processed in the SchemaTool context. This method detects them.

Method Details

__construct() public method

Initializes a new SchemaTool instance that uses the connection of the provided EntityManager.
public __construct ( EntityManager $em )
$em Doctrine\ORM\EntityManager

createSchema() public method

Creates the database schema for the given array of ClassMetadata instances.
public createSchema ( array $classes )
$classes array

dropDatabase() public method

Drops all elements in the database of the current connection.
public dropDatabase ( ) : void
return void

dropSchema() public method

In any way when an exception is thrown it is supressed since drop was issued for all classes of the schema and some probably just don't exist.
public dropSchema ( array $classes ) : void
$classes array
return void

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.

getDropDatabaseSQL() public method

Gets the SQL needed to drop the database schema for the connections database.
public getDropDatabaseSQL ( ) : array
return array

getDropSchemaSQL() public method

public getDropSchemaSQL ( array $classes ) : array
$classes array
return array

getSchemaFromMetadata() public method

From a given set of metadata classes this method creates a Schema instance.
public getSchemaFromMetadata ( array $classes ) : Schema
$classes array
return Schema

getUpdateSchemaSql() public method

Gets the sequence of SQL statements that need to be performed in order to bring the given class mappings in-synch with the relational schema.
public getUpdateSchemaSql ( array $classes, $saveMode = false ) : array
$classes array The classes to consider.
return array The sequence of SQL statements.

updateSchema() public method

Updates the database schema of the given classes by comparing the ClassMetadata ins$tableNametances to the current database schema that is inspected.
public updateSchema ( array $classes, $saveMode = false ) : void
$classes array
return void