Doctrine


Doctrine\DBAL\Schema\AbstractSchemaManager
/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 41

Class AbstractSchemaManager

AbstractSchemaManager

public abstract class AbstractSchemaManager

Base class for schema managers. Schema managers are used to inspect and/or modify the database schema/structure.

License:
http://www.opensource.org/licenses/lgpl-license.php LGPL
Author:
Konsta Vesterinen
Lukas Smith (PEAR MDB2 library)
Roman Borschel
Jonathan H. Wage
Benjamin Eberlei
Version:
$Revision$
Since:
2.0

Field Summary
protected \Doctrine\DBAL\Connection

$_conn

Holds instance of the Doctrine connection for this schema manager

protected \Doctrine\DBAL\Platforms\AbstractPlatform

$_platform

Holds instance of the database platform used for this schema manager

Constructor Summary

AbstractSchemaManager(\Doctrine\DBAL\Connection conn)

Constructor.

Method Summary
void

alterTable(TableDiff tableDiff)

Alter an existing tables schema

void

createConstraint(Constraint constraint, string|Table table)

Create a constraint on a table

void

createDatabase(string database)

Creates a new database.

void

createForeignKey(ForeignKeyConstraint foreignKey, string|Table table)

Create a new foreign key

void

createIndex(Index index, string table)

Create a new index on a table

Schema

createSchema()

Create a schema instance for the current database.

SchemaConfig

createSchemaConfig()

Create the configuration for this schema.

void

createSequence(Sequence sequence)

Create a new sequence

void

createTable(Table table, int createFlags)

Create a new table.

void

createView(View view)

Create a new view

void

dropAndCreateConstraint(Constraint constraint, string table)

Drop and create a constraint

void

dropAndCreateDatabase(string database)

Drop and creates a new database.

void

dropAndCreateForeignKey(ForeignKeyConstraint foreignKey, string|Table table)

Drop and create a new foreign key

void

dropAndCreateIndex(Index index, string|Table table)

Drop and create a new index on a table

void

dropAndCreateSequence(Sequence sequence)

Drop and create a new sequence

void

dropAndCreateTable(Table table)

Drop and create a new table.

void

dropAndCreateView(View view)

Drop and create a new view

void

dropConstraint(Constraint constraint, string table)

Drop the constraint from the given table

void

dropDatabase(string database)

Drops a database.

boolean

dropForeignKey(mixed foreignKey, ForeignKeyConstraint|string table, Table|string name)

Drops a foreign key from a table.

void

dropIndex(Index|string index, string|Table table)

Drop the index from the given table

void

dropSequence(string name)

Drops a sequence with a given name.

void

dropTable(string table)

Drop the given table

boolean

dropView(string name)

Drop a view

\Doctrine\DBAL\Platform\AbstractPlatform

getDatabasePlatform()

Return associated platform.

array

listDatabases()

List the available databases for this connection

Sequence[]

listSequences(mixed database)

List the available sequences for this connection

Column[]

listTableColumns(string table)

List the columns for a given table.

Table

listTableDetails(string tableName)

ForeignKeyConstraint[]

listTableForeignKeys(string table, mixed database)

List the foreign keys for the given table

Index[]

listTableIndexes(string table)

List the indexes for a given table returning an array of Index instances.

array

listTableNames()

Return a list of all tables in the current database

Table[]

listTables()

List the tables for this connection

View[]

listViews()

List the views this connection has

void

renameTable(string name, string newName)

Rename a given table to another name

mixed

tryMethod()

Try any method on the schema manager.

Field Detail

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 48

_conn

protected \Doctrine\DBAL\Connection $_conn

Holds instance of the Doctrine connection for this schema manager


/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 55

_platform

protected \Doctrine\DBAL\Platforms\AbstractPlatform $_platform

Holds instance of the database platform used for this schema manager


Constructor Detail

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 62

AbstractSchemaManager

public AbstractSchemaManager(\Doctrine\DBAL\Connection conn)

Constructor. Accepts the Connection instance to manage the schema for


Method Detail

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 512

alterTable

public void alterTable(TableDiff tableDiff)

Alter an existing tables schema


/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 383

createConstraint

public void createConstraint(Constraint constraint, string|Table table)

Create a constraint on a table


/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 349

createDatabase

public void createDatabase(string database)

Creates a new database.

Parameters:
database - The name of the database to create.

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 405

createForeignKey

public void createForeignKey(ForeignKeyConstraint foreignKey, string|Table table)

Create a new foreign key

Parameters:
foreignKey - ForeignKey instance
table - name of the table on which the foreign key is to be created

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 394

createIndex

public void createIndex(Index index, string table)

Create a new index on a table

Parameters:
table - name of the table on which the index is to be created

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 750

createSchema

public Schema createSchema()

Create a schema instance for the current database.


/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 766

createSchemaConfig

public SchemaConfig createSchemaConfig()

Create the configuration for this schema.


/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 372

createSequence

public void createSequence(Sequence sequence)

Create a new sequence

Throws:
if something fails at database level

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 360

createTable

public void createTable(Table table, int createFlags)

Create a new table.


/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 415

createView

public void createView(View view)

Create a new view


/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 430

dropAndCreateConstraint

public void dropAndCreateConstraint(Constraint constraint, string table)

Drop and create a constraint

See Also:
dropConstraint()
createConstraint()

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 488

dropAndCreateDatabase

public void dropAndCreateDatabase(string database)

Drop and creates a new database.

Parameters:
database - The name of the database to create.

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 454

dropAndCreateForeignKey

public void dropAndCreateForeignKey(ForeignKeyConstraint foreignKey, string|Table table)

Drop and create a new foreign key

Parameters:
foreignKey - associative array that defines properties of the foreign key to be created.
table - name of the table on which the foreign key is to be created

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 442

dropAndCreateIndex

public void dropAndCreateIndex(Index index, string|Table table)

Drop and create a new index on a table

Parameters:
table - name of the table on which the index is to be created

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 466

dropAndCreateSequence

public void dropAndCreateSequence(Sequence sequence)

Drop and create a new sequence

Throws:
if something fails at database level

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 477

dropAndCreateTable

public void dropAndCreateTable(Table table)

Drop and create a new table.


/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 499

dropAndCreateView

public void dropAndCreateView(View view)

Drop and create a new view


/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 304

dropConstraint

public void dropConstraint(Constraint constraint, string table)

Drop the constraint from the given table

Parameters:
table - The name of the table

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 268

dropDatabase

public void dropDatabase(string 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

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 316

dropForeignKey

public boolean dropForeignKey(mixed foreignKey, ForeignKeyConstraint|string table, Table|string name)

Drops a foreign key from a table.

Parameters:
table - The name of the table with the foreign key.
name - The name of the foreign key.
Returns:
$result

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 289

dropIndex

public void dropIndex(Index|string index, string|Table table)

Drop the index from the given table

Parameters:
index - The name of the index
table - The name of the table

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 326

dropSequence

public void dropSequence(string name)

Drops a sequence with a given name.

Parameters:
name - The name of the sequence to drop.

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 278

dropTable

public void dropTable(string table)

Drop the given table

Parameters:
table - The name of the table to drop

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 337

dropView

public boolean dropView(string name)

Drop a view

Parameters:
name - The name of the view
Returns:
$result

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 73

getDatabasePlatform

public \Doctrine\DBAL\Platform\AbstractPlatform getDatabasePlatform()

Return associated platform.


/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 109

listDatabases

public array listDatabases()

List the available databases for this connection

Returns:
$databases

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 123

listSequences

public Sequence[] listSequences(mixed database)

List the available sequences for this connection


/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 148

listTableColumns

public Column[] listTableColumns(string table)

List 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' field for the reason that it is not portable accross different RDBMS. Use listTableIndexes($tableName) to retrieve the primary key of a table. We're a RDBMS specifies more details these are held in the platformDetails array.

Parameters:
table - The name of the table.

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 209

listTableDetails

public Table listTableDetails(string tableName)


/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 248

listTableForeignKeys

public ForeignKeyConstraint[] listTableForeignKeys(string table, mixed database)

List the foreign keys for the given table

Parameters:
table - The name of the table

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 165

listTableIndexes

public Index[] listTableIndexes(string table)

List 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
Returns:
$tableIndexes

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 179

listTableNames

public array listTableNames()

Return a list of all tables in the current database


/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 193

listTables

public Table[] listTables()

List the tables for this connection


/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 233

listViews

public View[] listViews()

List the views this connection has


/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 528

renameTable

public void renameTable(string name, string newName)

Rename a given table to another name

Parameters:
name - The current name of the table
newName - The new name of the table

/Doctrine/DBAL/Schema/AbstractSchemaManager.php at line 90

tryMethod

public mixed tryMethod()

Try 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');


Doctrine