Documentation

Table extends AbstractAsset
in package

Object Representation of a table.

Tags
link
www.doctrine-project.org
since
2.0
author

Benjamin Eberlei kontakt@beberlei.de

Table of Contents

$_columns  : array<string|int, Column>
$_fkConstraints  : array<string|int, ForeignKeyConstraint>
$_indexes  : array<string|int, Index>
$_name  : string
$_namespace  : string|null
Namespace of the asset. If none isset the default namespace is assumed.
$_options  : array<string|int, mixed>
$_primaryKeyName  : string
$_quoted  : bool
$_schemaConfig  : SchemaConfig
$implicitIndexes  : array<string|int, Index>
__clone()  : void
Clone of a Table triggers a deep clone of all affected assets.
__construct()  : mixed
addColumn()  : Column
addForeignKeyConstraint()  : self
Adds a foreign key constraint.
addIndex()  : self
addNamedForeignKeyConstraint()  : self
Adds a foreign key constraint with a given name.
addOption()  : self
addUniqueIndex()  : self
addUnnamedForeignKeyConstraint()  : self
Adds a foreign key constraint.
changeColumn()  : self
Change Column Details.
columnsAreIndexed()  : bool
Checks if an index begins in the order of the given columns.
dropColumn()  : self
Drops a Column from the Table.
dropIndex()  : void
Drops an index from this table.
dropPrimaryKey()  : void
Drops the primary key from this table.
getColumn()  : Column
Returns the Column with the given name.
getColumns()  : array<string|int, Column>
getForeignKey()  : ForeignKeyConstraint
Returns the foreign key constraint with the given name.
getForeignKeys()  : array<string|int, ForeignKeyConstraint>
Returns the foreign key constraints.
getFullQualifiedName()  : string
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.
getIndex()  : Index
Returns the Index with the given name.
getIndexes()  : array<string|int, Index>
getName()  : string
Returns the name of this schema asset.
getNamespaceName()  : string|null
Gets the namespace name of this asset.
getOption()  : mixed
getOptions()  : array<string|int, mixed>
getPrimaryKey()  : Index|null
Returns the primary key.
getPrimaryKeyColumns()  : array<string|int, mixed>
Returns the primary key columns.
getQuotedName()  : string
Gets the quoted representation of this asset but only if it was defined with one. Otherwise return the plain unquoted value as inserted.
getShortestName()  : string
The shortest name is stripped of the default namespace. All other namespaced elements are returned as full-qualified names.
hasColumn()  : bool
Returns whether this table has a Column with the given name.
hasForeignKey()  : bool
Returns whether this table has a foreign key constraint with the given name.
hasIndex()  : bool
Returns whether this table has an Index with the given name.
hasOption()  : bool
hasPrimaryKey()  : bool
Returns whether this table has a primary key.
isInDefaultNamespace()  : bool
Is this asset in the default namespace?
isQuoted()  : bool
Checks if this asset's name is quoted.
removeForeignKey()  : void
Removes the foreign key constraint with the given name.
renameColumn()  : self
Renames a Column.
renameIndex()  : self
Renames an index.
setPrimaryKey()  : self
Sets the Primary Key.
setSchemaConfig()  : void
visit()  : void
_addColumn()  : void
_addForeignKeyConstraint()  : void
_addIndex()  : self
Adds an index to the table.
_generateIdentifierName()  : string
Generates an identifier from a list of column names obeying a certain string length.
_getMaxIdentifierLength()  : int
_setName()  : void
Sets the name of this asset.
isIdentifierQuoted()  : bool
Checks if this identifier is quoted.
trimQuotes()  : string
Trim quotes from the identifier.
_createIndex()  : Index
normalizeIdentifier()  : string
Normalizes a given identifier.

Properties

$_columns

protected array<string|int, Column> $_columns = array()

$_indexes

protected array<string|int, Index> $_indexes = array()

$_name

protected string $_name = null

$_namespace

Namespace of the asset. If none isset the default namespace is assumed.

protected string|null $_namespace = null

$_options

protected array<string|int, mixed> $_options = array()

$_primaryKeyName

protected string $_primaryKeyName = false

$implicitIndexes

private array<string|int, Index> $implicitIndexes = array()

Methods

__clone()

Clone of a Table triggers a deep clone of all affected assets.

public __clone() : void
Return values
void

__construct()

public __construct(string $tableName[, array<string|int, Column$columns = array() ][, array<string|int, Index$indexes = array() ][, array<string|int, ForeignKeyConstraint$fkConstraints = array() ], int $idGeneratorType[, array<string|int, mixed> $options = array() ]) : mixed
Parameters
$tableName : string
$columns : array<string|int, Column> = array()
$indexes : array<string|int, Index> = array()
$fkConstraints : array<string|int, ForeignKeyConstraint> = array()
$idGeneratorType : int
$options : array<string|int, mixed> = array()
Tags
throws
DBALException
Return values
mixed

addColumn()

public addColumn(string $columnName, string $typeName[, array<string|int, mixed> $options = array() ]) : Column
Parameters
$columnName : string
$typeName : string
$options : array<string|int, mixed> = array()
Return values
Column

addForeignKeyConstraint()

Adds a foreign key constraint.

public addForeignKeyConstraint(Table|string $foreignTable, array<string|int, mixed> $localColumnNames, array<string|int, mixed> $foreignColumnNames[, array<string|int, mixed> $options = array() ][, string|null $constraintName = null ]) : self

Name is inferred from the local columns.

Parameters
$foreignTable : Table|string

Table schema instance or table name

$localColumnNames : array<string|int, mixed>
$foreignColumnNames : array<string|int, mixed>
$options : array<string|int, mixed> = array()
$constraintName : string|null = null
Return values
self

addIndex()

public addIndex(array<string|int, mixed> $columnNames[, string|null $indexName = null ][, array<string|int, mixed> $flags = array() ][, array<string|int, mixed> $options = array() ]) : self
Parameters
$columnNames : array<string|int, mixed>
$indexName : string|null = null
$flags : array<string|int, mixed> = array()
$options : array<string|int, mixed> = array()
Return values
self

addNamedForeignKeyConstraint()

Adds a foreign key constraint with a given name.

public addNamedForeignKeyConstraint(string $name, Table|string $foreignTable, array<string|int, mixed> $localColumnNames, array<string|int, mixed> $foreignColumnNames[, array<string|int, mixed> $options = array() ]) : self
Parameters
$name : string
$foreignTable : Table|string

Table schema instance or table name

$localColumnNames : array<string|int, mixed>
$foreignColumnNames : array<string|int, mixed>
$options : array<string|int, mixed> = array()
Tags
deprecated

Use

throws
SchemaException
Return values
self

addOption()

public addOption(string $name, string $value) : self
Parameters
$name : string
$value : string
Return values
self

addUniqueIndex()

public addUniqueIndex(array<string|int, mixed> $columnNames[, string|null $indexName = null ][, array<string|int, mixed> $options = array() ]) : self
Parameters
$columnNames : array<string|int, mixed>
$indexName : string|null = null
$options : array<string|int, mixed> = array()
Return values
self

addUnnamedForeignKeyConstraint()

Adds a foreign key constraint.

public addUnnamedForeignKeyConstraint(Table|string $foreignTable, array<string|int, mixed> $localColumnNames, array<string|int, mixed> $foreignColumnNames[, array<string|int, mixed> $options = array() ]) : self

Name is to be generated by the database itself.

Parameters
$foreignTable : Table|string

Table schema instance or table name

$localColumnNames : array<string|int, mixed>
$foreignColumnNames : array<string|int, mixed>
$options : array<string|int, mixed> = array()
Tags
deprecated

Use

Return values
self

changeColumn()

Change Column Details.

public changeColumn(string $columnName, array<string|int, mixed> $options) : self
Parameters
$columnName : string
$options : array<string|int, mixed>
Return values
self

columnsAreIndexed()

Checks if an index begins in the order of the given columns.

public columnsAreIndexed(array<string|int, mixed> $columnsNames) : bool
Parameters
$columnsNames : array<string|int, mixed>
Return values
bool

dropColumn()

Drops a Column from the Table.

public dropColumn(string $columnName) : self
Parameters
$columnName : string
Return values
self

dropIndex()

Drops an index from this table.

public dropIndex(string $indexName) : void
Parameters
$indexName : string

The index name.

Tags
throws
SchemaException

If the index does not exist.

Return values
void

dropPrimaryKey()

Drops the primary key from this table.

public dropPrimaryKey() : void
Return values
void

getColumn()

Returns the Column with the given name.

public getColumn(string $columnName) : Column
Parameters
$columnName : string

The column name.

Tags
throws
SchemaException

If the column does not exist.

Return values
Column

getColumns()

public getColumns() : array<string|int, Column>
Return values
array<string|int, Column>

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.

public getFullQualifiedName(string $defaultNamespaceName) : string

Every non-namespaced element is prefixed with the default namespace name which is passed as argument to this method.

Parameters
$defaultNamespaceName : string
Return values
string

getIndex()

Returns the Index with the given name.

public getIndex(string $indexName) : Index
Parameters
$indexName : string

The index name.

Tags
throws
SchemaException

If the index does not exist.

Return values
Index

getIndexes()

public getIndexes() : array<string|int, Index>
Return values
array<string|int, Index>

getName()

Returns the name of this schema asset.

public getName() : string
Return values
string

getNamespaceName()

Gets the namespace name of this asset.

public getNamespaceName() : string|null

If NULL is returned this means the default namespace is used.

Return values
string|null

getOption()

public getOption(string $name) : mixed
Parameters
$name : string
Return values
mixed

getOptions()

public getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>

getPrimaryKey()

Returns the primary key.

public getPrimaryKey() : Index|null
Return values
Index|null

The primary key, or null if this Table has no primary key.

getPrimaryKeyColumns()

Returns the primary key columns.

public getPrimaryKeyColumns() : array<string|int, mixed>
Tags
throws
DBALException
Return values
array<string|int, mixed>

getQuotedName()

Gets the quoted representation of this asset but only if it was defined with one. Otherwise return the plain unquoted value as inserted.

public getQuotedName(AbstractPlatform $platform) : string
Parameters
$platform : AbstractPlatform
Return values
string

getShortestName()

The shortest name is stripped of the default namespace. All other namespaced elements are returned as full-qualified names.

public getShortestName(string $defaultNamespaceName) : string
Parameters
$defaultNamespaceName : string
Return values
string

hasColumn()

Returns whether this table has a Column with the given name.

public hasColumn(string $columnName) : bool
Parameters
$columnName : string

The column name.

Return values
bool

hasForeignKey()

Returns whether this table has a foreign key constraint with the given name.

public hasForeignKey(string $constraintName) : bool
Parameters
$constraintName : string
Return values
bool

hasIndex()

Returns whether this table has an Index with the given name.

public hasIndex(string $indexName) : bool
Parameters
$indexName : string

The index name.

Return values
bool

hasOption()

public hasOption(string $name) : bool
Parameters
$name : string
Return values
bool

hasPrimaryKey()

Returns whether this table has a primary key.

public hasPrimaryKey() : bool
Return values
bool

isInDefaultNamespace()

Is this asset in the default namespace?

public isInDefaultNamespace(string $defaultNamespaceName) : bool
Parameters
$defaultNamespaceName : string
Return values
bool

isQuoted()

Checks if this asset's name is quoted.

public isQuoted() : bool
Return values
bool

removeForeignKey()

Removes the foreign key constraint with the given name.

public removeForeignKey(string $constraintName) : void
Parameters
$constraintName : string

The constraint name.

Tags
throws
SchemaException
Return values
void

renameColumn()

Renames a Column.

public renameColumn(string $oldColumnName, string $newColumnName) : self
Parameters
$oldColumnName : string
$newColumnName : string
Tags
throws
DBALException
Return values
self

renameIndex()

Renames an index.

public renameIndex(string $oldIndexName[, string|null $newIndexName = null ]) : self
Parameters
$oldIndexName : string

The name of the index to rename from.

$newIndexName : string|null = null

The name of the index to rename to. If null is given, the index name will be auto-generated.

Tags
throws
SchemaException

if no index exists for the given current name or if an index with the given new name already exists on this table.

Return values
self

This table instance.

setPrimaryKey()

Sets the Primary Key.

public setPrimaryKey(array<string|int, mixed> $columns[, string|bool $indexName = false ]) : self
Parameters
$columns : array<string|int, mixed>
$indexName : string|bool = false
Return values
self

visit()

public visit(Visitor $visitor) : void
Parameters
$visitor : Visitor
Return values
void

_addIndex()

Adds an index to the table.

protected _addIndex(Index $indexCandidate) : self
Parameters
$indexCandidate : Index
Tags
throws
SchemaException
Return values
self

_generateIdentifierName()

Generates an identifier from a list of column names obeying a certain string length.

protected _generateIdentifierName(array<string|int, mixed> $columnNames[, string $prefix = '' ][, int $maxSize = 30 ]) : string

This is especially important for Oracle, since it does not allow identifiers larger than 30 chars, however building idents automatically for foreign keys, composite keys or such can easily create very long names.

Parameters
$columnNames : array<string|int, mixed>
$prefix : string = ''
$maxSize : int = 30
Return values
string

_getMaxIdentifierLength()

protected _getMaxIdentifierLength() : int
Return values
int

_setName()

Sets the name of this asset.

protected _setName(string $name) : void
Parameters
$name : string
Return values
void

isIdentifierQuoted()

Checks if this identifier is quoted.

protected isIdentifierQuoted(string $identifier) : bool
Parameters
$identifier : string
Return values
bool

trimQuotes()

Trim quotes from the identifier.

protected trimQuotes(string $identifier) : string
Parameters
$identifier : string
Return values
string

_createIndex()

private _createIndex(array<string|int, mixed> $columnNames, string $indexName, bool $isUnique, bool $isPrimary[, array<string|int, mixed> $flags = array() ][, array<string|int, mixed> $options = array() ]) : Index
Parameters
$columnNames : array<string|int, mixed>
$indexName : string
$isUnique : bool
$isPrimary : bool
$flags : array<string|int, mixed> = array()
$options : array<string|int, mixed> = array()
Tags
throws
SchemaException
Return values
Index

normalizeIdentifier()

Normalizes a given identifier.

private normalizeIdentifier(string $identifier) : string

Trims quotes and lowercases the given identifier.

Parameters
$identifier : string

The identifier to normalize.

Return values
string

The normalized identifier.

Search results