Methods |
public
|
__construct(Connection $conn, ?AbstractPlatform $platform = null)
Constructor. Accepts the Connection instance to manage the schema for.
Constructor. Accepts the Connection instance to manage the schema for.
|
#
|
public
|
getDatabasePlatform(): AbstractPlatform
Returns the associated platform.
Returns the associated platform.
|
#
|
public
|
tryMethod(): mixed
Tries any method on the schema manager. Normally a method throws an
exception when your DBMS doesn't support it or if…
Tries any method on the schema manager. Normally a method throws an
exception when your DBMS doesn't support it or if an error occurs.
This method allows you to try and method on your SchemaManager
instance and will return false if it does not work or is not supported.
$result = $sm->tryMethod('dropView', 'view_name');
|
#
|
public
|
listDatabases(): string[]
Lists the available databases for this connection.
Lists the available databases for this connection.
|
#
|
public
|
listNamespaceNames(): string[]
Returns a list of all namespaces in the current database.
Returns a list of all namespaces in the current database.
|
#
|
public
|
listSequences(string|null $database = null): Sequence[]
Lists the available sequences for this connection.
Lists the available sequences for this connection.
|
#
|
public
|
listTableColumns(string $table, string|null $database = null): Column[]
Lists the columns for a given table.
Lists the columns for a given table.
In contrast to other libraries and to the old version of Doctrine,
this column definition does try to contain the 'primary' column for
the reason that it is not portable across different RDBMS. Use
{@see listTableIndexes($tableName)} to retrieve the primary key
of a table. Where a RDBMS specifies more details, these are held
in the platformDetails array.
Parameters
$table |
The name of the table.
|
|
#
|
public
|
listTableIndexes(string $table): Index[]
Lists the indexes for a given table returning an array of Index instances.
Lists the indexes for a given table returning an array of Index instances.
Keys of the portable indexes list are all lower-cased.
Parameters
$table |
The name of the table.
|
|
#
|
public
|
tablesExist(string|string[] $names): bool
Returns true if all the given tables exist.
Returns true if all the given tables exist.
The usage of a string $tableNames is deprecated. Pass a one-element array instead.
|
#
|
public
|
listTableNames(): string[]
Returns a list of all tables in the current database.
Returns a list of all tables in the current database.
|
#
|
public
|
listTables(): Table[]
Lists the tables for this connection.
Lists the tables for this connection.
|
#
|
public
|
listTableDetails(string $name): Table
|
#
|
public
|
listViews(): View[]
Lists the views this connection has.
Lists the views this connection has.
|
#
|
public
|
listTableForeignKeys(string $table, string|null $database = null): ForeignKeyConstraint[]
Lists the foreign keys for the given table.
Lists the foreign keys for the given table.
Parameters
$table |
The name of the table.
|
|
#
|
public
|
dropDatabase(string $database): void
Drops a database.
Drops a database.
NOTE: You can not drop the database this SchemaManager is currently connected to.
Parameters
$database |
The name of the database to drop.
|
|
#
|
public
|
dropTable(string $name): void
Drops the given table.
Parameters
$name |
The name of the table to drop.
|
|
#
|
public
|
dropIndex(Index|string $index, Table|string $table): void
Drops the index from the given table.
Drops the index from the given table.
Parameters
$index |
The name of the index.
|
$table |
The name of the table.
|
|
#
|
public
|
dropConstraint(Constraint $constraint, Table|string $table): void
Drops the constraint from the given table.
Drops the constraint from the given table.
Parameters
$table |
The name of the table.
|
|
#
|
public
|
dropForeignKey(ForeignKeyConstraint|string $foreignKey, Table|string $table): void
Drops a foreign key from a table.
Drops a foreign key from a table.
Parameters
$foreignKey |
The name of the foreign key.
|
$table |
The name of the table with the foreign key.
|
|
#
|
public
|
dropSequence(string $name): void
Drops a sequence with a given name.
Drops a sequence with a given name.
Parameters
$name |
The name of the sequence to drop.
|
|
#
|
public
|
dropView(string $name): void
Drops a view.
Parameters
$name |
The name of the view.
|
|
#
|
public
|
createDatabase(string $database): void
Creates a new database.
Parameters
$database |
The name of the database to create.
|
|
#
|
public
|
createTable(Table $table): void
Creates a new table.
|
#
|
public
|
createSequence(Sequence $sequence): void
Creates a new sequence.
|
#
|
public
|
createConstraint(Constraint $constraint, Table|string $table): void
Creates a constraint on a table.
Creates a constraint on a table.
|
#
|
public
|
createIndex(Index $index, Table|string $table): void
Creates a new index on a table.
Creates a new index on a table.
Parameters
$table |
The name of the table on which the index is to be created.
|
|
#
|
public
|
createForeignKey(ForeignKeyConstraint $foreignKey, Table|string $table): void
Creates a new foreign key.
Creates a new foreign key.
Parameters
$foreignKey |
The ForeignKey instance.
|
$table |
The name of the table on which the foreign key is to be created.
|
|
#
|
public
|
createView(View $view): void
Creates a new view.
|
#
|
public
|
dropAndCreateConstraint(Constraint $constraint, Table|string $table): void
Drops and creates a constraint.
Drops and creates a constraint.
|
#
|
public
|
dropAndCreateIndex(Index $index, Table|string $table): void
Drops and creates a new index on a table.
Drops and creates a new index on a table.
Parameters
$table |
The name of the table on which the index is to be created.
|
|
#
|
public
|
dropAndCreateForeignKey(ForeignKeyConstraint $foreignKey, Table|string $table): void
Drops and creates a new foreign key.
Drops and creates a new foreign key.
Parameters
$foreignKey |
An associative array that defines properties
of the foreign key to be created.
|
$table |
The name of the table on which the foreign key is to be created.
|
|
#
|
public
|
dropAndCreateSequence(Sequence $sequence): void
Drops and create a new sequence.
Drops and create a new sequence.
Throws
|
#
|
public
|
dropAndCreateTable(Table $table): void
Drops and creates a new table.
Drops and creates a new table.
|
#
|
public
|
dropAndCreateDatabase(string $database): void
Drops and creates a new database.
Drops and creates a new database.
Parameters
$database |
The name of the database to create.
|
|
#
|
public
|
dropAndCreateView(View $view): void
Drops and creates a new view.
Drops and creates a new view.
|
#
|
public
|
alterTable(TableDiff $tableDiff): void
Alters an existing tables schema.
Alters an existing tables schema.
|
#
|
public
|
renameTable(string $name, string $newName): void
Renames a given table to another name.
Renames a given table to another name.
Parameters
$name |
The current name of the table.
|
$newName |
The new name of the table.
|
|
#
|
public
|
createSchema(): Schema
Creates a schema instance for the current database.
Creates a schema instance for the current database.
|
#
|
public
|
createSchemaConfig(): SchemaConfig
Creates the configuration for this schema.
Creates the configuration for this schema.
|
#
|
public
|
getSchemaSearchPaths(): string[]
The search path for namespaces in the currently connected database.
The search path for namespaces in the currently connected database.
The first entry is usually the default namespace in the Schema. All
further namespaces contain tables/sequences which can also be addressed
with a short, not full-qualified name.
For databases that don't support subschema/namespaces this method
returns the name of the currently connected database.
|
#
|
public
|
extractDoctrineTypeFromComment(string|null $comment, string $currentType): string
Given a table comment this method tries to extract a typehint for Doctrine Type, or returns
the type given as default.
Given a table comment this method tries to extract a typehint for Doctrine Type, or returns
the type given as default.
|
#
|
public
|
removeDoctrineTypeFromComment(string|null $comment, string|null $type): string|null
|
#
|