Documentation

Table extends AbstractAsset
in package

Object Representation of a table.

Table of Contents

Properties

$_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|null
$_quoted  : bool
$_schemaConfig  : SchemaConfig|null
$uniqueConstraints  : array<string|int, UniqueConstraint>
$implicitIndexes  : array<string|int, Index>

Methods

__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
addOption()  : self
addUniqueConstraint()  : self
addUniqueIndex()  : self
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>
Returns ordered list of columns (primary keys are first, then foreign keys, then the rest)
getComment()  : string|null
getForeignKey()  : ForeignKeyConstraint
Returns the foreign key constraint with the given name.
getForeignKeyColumns()  : array<string|int, Column>
Returns the foreign key columns
getForeignKeys()  : array<string|int, ForeignKeyConstraint>
Returns the foreign key constraints.
getFullQualifiedName()  : string
The normalized name is full-qualified and lower-cased. Lower-casing 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, Column>
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.
getUniqueConstraint()  : UniqueConstraint
Returns the unique constraint with the given name.
getUniqueConstraints()  : array<string|int, UniqueConstraint>
Returns the unique constraints.
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.
hasUniqueConstraint()  : bool
Returns whether this table has a unique constraint with the given name.
isInDefaultNamespace()  : bool
Is this asset in the default namespace?
isQuoted()  : bool
Checks if this asset's name is quoted.
modifyColumn()  : self
removeForeignKey()  : void
Removes the foreign key constraint with the given name.
removeUniqueConstraint()  : void
Removes the unique constraint with the given name.
renameIndex()  : self
Renames an index.
setComment()  : self
setPrimaryKey()  : self
Sets the Primary Key.
setSchemaConfig()  : void
visit()  : void
_addColumn()  : void
_addForeignKeyConstraint()  : self
_addIndex()  : self
Adds an index to the table.
_addUniqueConstraint()  : self
_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
_createUniqueConstraint()  : UniqueConstraint
filterColumns()  : array<string|int, Column>
Returns only columns that have specified names
normalizeIdentifier()  : string
Normalizes a given identifier.

Properties

$_columns

protected array<string|int, Column> $_columns = []

$_indexes

protected array<string|int, Index> $_indexes = []

$_namespace

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

protected string|null $_namespace

$_options

protected array<string|int, mixed> $_options = ['create_options' => []]

$_primaryKeyName

protected string|null $_primaryKeyName

$implicitIndexes

private array<string|int, Index> $implicitIndexes = []

Methods

__clone()

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

public __clone() : void

__construct()

public __construct(string $name[, array<string|int, Column$columns = [] ][, array<string|int, Index$indexes = [] ][, array<string|int, UniqueConstraint$uniqueConstraints = [] ][, array<string|int, ForeignKeyConstraint$fkConstraints = [] ][, array<string|int, mixed> $options = [] ]) : mixed
Parameters
$name : string
$columns : array<string|int, Column> = []
$indexes : array<string|int, Index> = []
$uniqueConstraints : array<string|int, UniqueConstraint> = []
$fkConstraints : array<string|int, ForeignKeyConstraint> = []
$options : array<string|int, mixed> = []
Tags
throws
SchemaException
throws
Exception

addColumn()

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

addForeignKeyConstraint()

Adds a foreign key constraint.

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

Name is inferred from the local columns.

Parameters
$foreignTable : Table|string

Table schema instance or table name

$localColumnNames : array<string|int, string>
$foreignColumnNames : array<string|int, string>
$options : array<string|int, mixed> = []
$name : string|null = null
Tags
throws
SchemaException
Return values
self

addIndex()

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

addOption()

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

addUniqueConstraint()

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

addUniqueIndex()

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

changeColumn()

Change Column Details.

public changeColumn(string $name, array<string|int, mixed> $options) : self
Parameters
$name : string
$options : array<string|int, mixed>
Tags
deprecated

Use instead.

throws
SchemaException
Return values
self

columnsAreIndexed()

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

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

dropColumn()

Drops a Column from the Table.

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

dropIndex()

Drops an index from this table.

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

The index name.

Tags
throws
SchemaException

If the index does not exist.

dropPrimaryKey()

Drops the primary key from this table.

public dropPrimaryKey() : void
Tags
throws
SchemaException

getColumn()

Returns the Column with the given name.

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

The column name.

Tags
throws
SchemaException

If the column does not exist.

Return values
Column

getColumns()

Returns ordered list of columns (primary keys are first, then foreign keys, then the rest)

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

getComment()

public getComment() : string|null
Return values
string|null

getFullQualifiedName()

The normalized name is full-qualified and lower-cased. Lower-casing 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
Tags
deprecated

Use getNamespaceName() and getName() instead.

Return values
string

getIndex()

Returns the Index with the given name.

public getIndex(string $name) : Index
Parameters
$name : 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

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, Column>
Tags
deprecated

Use getPrimaryKey() and Index::getColumns() instead.

throws
Exception
Return values
array<string|int, Column>

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|null $defaultNamespaceName) : string
Parameters
$defaultNamespaceName : string|null
Return values
string

hasColumn()

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

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

The column name.

Return values
bool

hasForeignKey()

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

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

hasIndex()

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

public hasIndex(string $name) : bool
Parameters
$name : 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
Tags
deprecated

Use getPrimaryKey() instead.

Return values
bool

hasUniqueConstraint()

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

public hasUniqueConstraint(string $name) : bool
Parameters
$name : string
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

modifyColumn()

public modifyColumn(string $name, array<string|int, mixed> $options) : self
Parameters
$name : string
$options : array<string|int, mixed>
Tags
throws
SchemaException
Return values
self

removeForeignKey()

Removes the foreign key constraint with the given name.

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

The constraint name.

Tags
throws
SchemaException

removeUniqueConstraint()

Removes the unique constraint with the given name.

public removeUniqueConstraint(string $name) : void
Parameters
$name : string
Tags
throws
SchemaException

If the unique constraint does not exist.

renameIndex()

Renames an index.

public renameIndex(string $oldName[, string|null $newName = null ]) : self
Parameters
$oldName : string

The name of the index to rename from.

$newName : 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.

setComment()

public setComment(string|null $comment) : self
Parameters
$comment : string|null
Return values
self

setPrimaryKey()

Sets the Primary Key.

public setPrimaryKey(array<string|int, string> $columnNames[, string|false $indexName = false ]) : self
Parameters
$columnNames : array<string|int, string>
$indexName : string|false = false
Tags
throws
SchemaException
Return values
self

_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, string> $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, string>
$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

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, string> $columnNames, string $indexName, bool $isUnique, bool $isPrimary[, array<string|int, string> $flags = [] ][, array<string|int, mixed> $options = [] ]) : Index
Parameters
$columnNames : array<string|int, string>
$indexName : string
$isUnique : bool
$isPrimary : bool
$flags : array<string|int, string> = []
$options : array<string|int, mixed> = []
Tags
throws
SchemaException
Return values
Index

_createUniqueConstraint()

private _createUniqueConstraint(array<string|int, string> $columnNames, string $indexName[, array<string|int, string> $flags = [] ][, array<string|int, mixed> $options = [] ]) : UniqueConstraint
Parameters
$columnNames : array<string|int, string>
$indexName : string
$flags : array<string|int, string> = []
$options : array<string|int, mixed> = []
Tags
throws
SchemaException
Return values
UniqueConstraint

filterColumns()

Returns only columns that have specified names

private filterColumns(array<string|int, string> $columnNames[, bool $reverse = false ]) : array<string|int, Column>
Parameters
$columnNames : array<string|int, string>
$reverse : bool = false
Return values
array<string|int, Column>

normalizeIdentifier()

Normalizes a given identifier.

private normalizeIdentifier(string|null $identifier) : string

Trims quotes and lowercases the given identifier.

Parameters
$identifier : string|null
Return values
string

The normalized identifier.


        
On this page

Search results