LENGTH_TINY
LENGTH_TINY = 255 : integer
Column length when using a `tiny` column type
Represents a single table in a database schema.
Can either be populated using the reflection API's or by incrementally building an instance using methods.
Once created TableSchema instances can be added to Schema\Collection objects. They can also be converted into SQL using the createSql(), dropSql() and truncateSql() methods.
None found |
columnType(string $name, string|null $type = null) : string|null
Sets the type of a column, or returns its current type if none is passed.
string | $name | The column to get the type of. |
string|null | $type | The type to set the column to. |
Either the column type or null.
None found |
None found |
None found |
None found |
None found |
None found |
None found |
None found |
addIndex(string $name, array $attrs) : $this
Add an index.
Used to add indexes, and full text indexes in platforms that support them.
type
The type of index being added.columns
The columns in the index.string | $name | The name of the index. |
array | $attrs | The attributes for the index. |
None found |
indexes() : array<mixed,string>
Get the names of all the indexes in the table.
None found |
index(string $name) : array|null
Read information about an index based on name.
string | $name | The name of the index. |
Array of index data, or null
None found |
getIndex(string $name) : array|null
Read information about an index based on name.
string | $name | The name of the index. |
Array of index data, or null
None found |
primaryKey() : array
Get the column(s) used for the primary key.
Column name(s) for the primary key. An empty list will be returned when the table has no primary key.
None found |
addConstraint(string $name, array $attrs) : $this
Add a constraint.
Used to add constraints to a table. For example primary keys, unique keys and foreign keys.
type
The type of constraint being added.columns
The columns in the index.references
The table, column a foreign key references.update
The behavior on update. Options are 'restrict', 'setNull', 'cascade', 'noAction'.delete
The behavior on delete. Options are 'restrict', 'setNull', 'cascade', 'noAction'.The default for 'update' & 'delete' is 'cascade'.
string | $name | The name of the constraint. |
array | $attrs | The attributes for the constraint. |
None found |
dropConstraint(string $name) : $this
Remove a constraint.
string | $name | Name of the constraint to remove |
None found |
hasAutoincrement() : boolean
Check whether or not a table has an autoIncrement column defined.
None found |
constraints() : array<mixed,string>
Get the names of all the constraints in the table.
None found |
constraint(string $name) : array|null
Read information about a constraint based on name.
string | $name | The name of the constraint. |
Array of constraint data, or null
None found |
getConstraint(string $name) : array|null
Read information about a constraint based on name.
string | $name | The name of the constraint. |
Array of constraint data, or null
None found |
None found |
None found |
options(array|null $options = null) : $this|array
Get/set the options for a table.
Table options allow you to set platform specific table level options. For example the engine type in MySQL.
array|null | $options | The options to set, or null to read options. |
Either the TableSchema instance, or an array of options when reading.
None found |
setTemporary(boolean $temporary) : $this
Sets whether the table is temporary in the database.
boolean | $temporary | Whether or not the table is to be temporary. |
None found |
isTemporary() : boolean
Gets whether the table is temporary in the database.
The current temporary setting.
None found |
temporary(boolean|null $temporary = null) : $this|boolean
Get/Set whether the table is temporary in the database
boolean|null | $temporary | whether or not the table is to be temporary |
Either the TableSchema instance, the current temporary setting
None found |
createSql(\Cake\Database\Connection $connection) : array
Generate the SQL to create the Table.
Uses the connection to access the schema dialect to generate platform specific SQL.
\Cake\Database\Connection | $connection | The connection to generate SQL for. |
List of SQL statements to create the table and the required indexes.
None found |
dropSql(\Cake\Database\Connection $connection) : array
Generate the SQL to drop a table.
Uses the connection to access the schema dialect to generate platform specific SQL.
\Cake\Database\Connection | $connection | The connection to generate SQL for. |
SQL to drop a table.
None found |
truncateSql(\Cake\Database\Connection $connection) : array
Generate the SQL statements to truncate a table
\Cake\Database\Connection | $connection | The connection to generate SQL for. |
SQL to truncate a table.
None found |
addConstraintSql(\Cake\Database\Connection $connection) : array
Generate the SQL statements to add the constraints to the table
\Cake\Database\Connection | $connection | The connection to generate SQL for. |
SQL to add the constraints.
None found |
dropConstraintSql(\Cake\Database\Connection $connection) : array
Generate the SQL statements to drop the constraints to the table
\Cake\Database\Connection | $connection | The connection to generate SQL for. |
SQL to drop a table.
None found |
None found |
_checkForeignKey(array $attrs) : array
Helper method to check/validate foreign keys.
array | $attrs | Attributes to set. |
When foreign key definition is not valid.
None found |