Interface TableSchemaInterface
An interface used by database TableSchema objects.
- Cake\Database\Schema\TableSchemaInterface implements Cake\Datasource\SchemaInterface
Direct Implementers
Constants summary
-
string
'biginteger'
-
string
'binary'
-
string
'boolean'
-
string
'date'
-
string
'datetime'
-
string
'decimal'
-
string
'float'
-
string
'integer'
-
string
'json'
-
string
'smallinteger'
-
string
'string'
-
string
'text'
-
string
'time'
-
string
'timestamp'
-
string
'tinyinteger'
-
string
'uuid'
Method Summary
- addConstraint() publicAdd a constraint.
- addIndex() publicAdd an index.
- constraints() publicGet the names of all the constraints in the table.
- dropConstraint() publicRemove a constraint.
- getConstraint() publicRead information about a constraint based on name.
- getIndex() publicRead information about an index based on name.
- hasAutoincrement() publicCheck whether or not a table has an autoIncrement column defined.
- indexes() publicGet the names of all the indexes in the table.
- isTemporary() publicGets whether the table is temporary in the database.
- primaryKey() publicGet the column(s) used for the primary key.
- setTemporary() publicSets whether the table is temporary in the database.
Method Detail
addConstraint()source public
addConstraint( string $name , array $attrs )
Add a constraint.
Used to add constraints to a table. For example primary keys, unique keys and foreign keys.
Attributes
-
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'.
Parameters
- string
$name
- The name of the constraint.
- array
$attrs
- The attributes for the constraint.
Returns
$this
addIndex()source public
addIndex( string $name , array $attrs )
Add an index.
Used to add indexes, and full text indexes in platforms that support them.
Attributes
-
type
The type of index being added. -
columns
The columns in the index.
Parameters
- string
$name
- The name of the index.
- array
$attrs
- The attributes for the index.
Returns
$this
constraints()source public
constraints( )
Get the names of all the constraints in the table.
Returns
arraydropConstraint()source public
dropConstraint( string $name )
Remove a constraint.
Parameters
- string
$name
- Name of the constraint to remove
Returns
$this
getConstraint()source public
getConstraint( string $name )
Read information about a constraint based on name.
Parameters
- string
$name
- The name of the constraint.
Returns
array|nullArray of constraint data, or null
getIndex()source public
getIndex( string $name )
Read information about an index based on name.
Parameters
- string
$name
- The name of the index.
Returns
array|nullArray of index data, or null
hasAutoincrement()source public
hasAutoincrement( )
Check whether or not a table has an autoIncrement column defined.
Returns
booleanisTemporary()source public
isTemporary( )
Gets whether the table is temporary in the database.
Returns
booleanThe current temporary setting.
primaryKey()source public
primaryKey( )
Get the column(s) used for the primary key.
Returns
arrayColumn name(s) for the primary key. An empty list will be returned when the table has no primary key.
setTemporary()source public
setTemporary( boolean $temporary )
Sets whether the table is temporary in the database.
Parameters
- boolean
$temporary
- Whether or not the table is to be temporary.
Returns
$this
© 2005–2017 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.4/class-Cake.Database.Schema.TableSchemaInterface.html