Doctrine\DBAL\Schema\Schema
Object representation of a database schema
Different vendors have very inconsistent naming with regard to the concept
of a "schema". Doctrine understands a schema as the entity that conceptually
wraps a set of database objects such as tables, sequences, indexes and
foreign keys that belong to each other into a namespace. A Doctrine Schema
has nothing to do with the "SCHEMA" defined as in PostgreSQL, it is more
related to the concept of "DATABASE" that exists in MySQL and PostgreSQL.
Every asset in the doctrine schema has a name. A name consists of either a
namespace.local name pair or just a local unqualified name.
The abstraction layer that covers a PostgreSQL schema is the namespace of an
database object (asset). A schema can have a name, which will be used as
default namespace for the unqualified database objects that are created in
the schema.
In the case of MySQL where cross-database queries are allowed this leads to
databases being "misinterpreted" as namespaces. This is intentional, however
the CREATE/DROP SQL visitors will just filter this queries and do not
execute them. Only the queries for the currently connected database are
executed.
- Author: Benjamin Eberlei <kontakt@beberlei.de>
Synopsis
- // members
- protected array $_tables;
- protected array $_sequences;
- protected SchemaConfig $_schemaConfig;
- // Inherited members from AbstractAsset
- protected string $_name;
- protected string $_namespace;
- protected bool $_quoted;
- // methods
- public void __construct()
- public bool hasExplicitForeignKeyIndexes()
- protected void _addTable()
- protected void _addSequence()
- public array getTables()
- public Table getTable()
- private string getFullQualifiedAssetName()
- public Schema hasTable()
- public array getTableNames()
- public void hasSequence()
- public Sequence getSequence()
- public array getSequences()
- public Table createTable()
- public Schema renameTable()
- public Schema dropTable()
- public Sequence createSequence()
- public Schema dropSequence()
- public array toSql()
- public array toDropSql()
- public void getMigrateToSql()
- public void getMigrateFromSql()
- public void visit()
- public void __clone()
- // Inherited methods from AbstractAsset
- protected void _setName()
- public bool isInDefaultNamespace()
- public string getNamespaceName()
- public string getShortestName()
- public string getFullQualifiedName()
- public bool isQuoted()
- protected bool isIdentifierQuoted()
- protected string trimQuotes()
- public string getName()
- public string getQuotedName()
- protected string _generateIdentifierName()
Hierarchy
Extends
Extended by
Members
protected
- $_name — string
- $_namespace
—
string
Namespace of the asset. If none isset the default namespace is assumed. - $_quoted — Doctrine\DBAL\Schema\bool
- $_schemaConfig — Doctrine\DBAL\Schema\SchemaConfig
- $_sequences — array
- $_tables — array
Methods
private
protected
public
- __construct()
- __clone() — Cloning a Schema triggers a deep clone of all related assets.
- createSequence() — Create a new sequence
- createTable() — Create a new table
- dropSequence()
- dropTable() — Drop a table from the schema.
- getMigrateFromSql()
- getMigrateToSql()
- getSequence()
- getSequences()
- getTable()
- getTableNames() — Get all table names, prefixed with a schema name, even the default one if present.
- getTables() — Get all tables of this schema.
- hasExplicitForeignKeyIndexes()
- hasSequence()
- hasTable() — Does this schema have a table with the given name?
- renameTable() — Rename a table
- toDropSql() — Return an array of necessary sql queries to drop the schema on the given platform.
- toSql() — Return an array of necessary sql queries to create the schema on the given platform.
- visit()
Inherited from Doctrine\DBAL\Schema\AbstractAsset
protected
- _generateIdentifierName() — Generate an identifier from a list of column names obeying a certain string length.
- _setName() — Set name of this asset
- isIdentifierQuoted() — Check if this identifier is quoted.
- trimQuotes() — Trim quotes from the identifier.
public
- getFullQualifiedName() — The normalized name is full-qualified and lowerspaced. Lowerspacing is actually wrong, but we have to do it to keep our sanity. If you are using database objects that only differentiate in the casing (FOO vs Foo) then you will NOT be able to use Doctrine Schema abstraction.
- getName() — Return name of this schema asset.
- getNamespaceName() — Get namespace name of this asset.
- getQuotedName() — Get the quoted representation of this asset but only if it was defined with one. Otherwise return the plain unquoted value as inserted.
- getShortestName() — The shortest name is stripped of the default namespace. All other namespaced elements are returned as full-qualified names.
- isInDefaultNamespace() — Is this asset in the default namespace?
- isQuoted() — Check if this asset's name is quoted