An interface used by TableSchema objects.
Returns the base type name for the provided column. This represent the database type a more complex class is based upon.
Returns an array where the keys are the column names in the schema and the values the database type they have.
addColumn( string $name , array $attrs )
Add a column to the table.
Columns can have several attributes:
type
The type of the column. This should be one of CakePHP's abstract types.length
The length of the column.precision
The number of decimal places to store for float and decimal types.default
The default value of the column.null
Whether or not the column can hold nulls.fixed
Whether or not the column is a fixed length column. This is only present/valid with string columns.unsigned
Whether or not the column is an unsigned column. This is only present/valid for integer, decimal, float columns.In addition to the above keys, the following keys are implemented in some database dialects, but not all:
comment
The comment for the column.$name
$attrs
baseColumnType( string $column )
Returns the base type name for the provided column. This represent the database type a more complex class is based upon.
$column
defaultValues( )
Get a hash of columns and their default values.
getColumn( string $name )
Get column data in the table.
$name
getColumnType( string $name )
Returns column type or null if a column does not exist.
$name
getOptions( )
Gets the options for a table.
Table options allow you to set platform specific table level options. For example the engine type in MySQL.
hasColumn( string $name )
Returns true if a column exists in the schema.
$name
isNullable( string $name )
Check whether or not a field is nullable
Missing columns are nullable.
$name
removeColumn( string $name )
Remove a column from the table schema.
If the column is not defined in the table, no error will be raised.
$name
setColumnType( string $name , string $type )
Sets the type of a column.
$name
$type
setOptions( array $options )
Sets the options for a table.
Table options allow you to set platform specific table level options. For example the engine type in MySQL.
$options
typeMap( )
Returns an array where the keys are the column names in the schema and the values the database type they have.
© 2005–2018 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/3.6/class-Cake.Datasource.SchemaInterface.html