Class MysqlSchema
Schema generation/reflection features for MySQL
Property Summary
- 
        $_driver protectedCake\Database\DriverThe driver instance being used. 
Method Summary
- 
          __construct() publicConstructor 
- 
          _convertColumn() protectedConvert a MySQL column type into an abstract type. 
- 
          _convertConstraintColumns() protectedConvert foreign key constraints references to a valid stringified list 
- 
          _convertOnClause() protectedConvert string on clauses to the abstract ones. 
- 
          _foreignOnClause() protectedGenerate an ON clause for a foreign key. 
- 
          _keySql() protectedHelper method for generating key SQL snippets. 
- 
          addConstraintSql() publicGenerate the SQL queries needed to add foreign key constraints to the table 
- 
          columnSql() publicGenerate the SQL fragment for a single column in a table. 
- 
          constraintSql() publicGenerate the SQL fragments for defining table constraints. 
- 
          convertColumnDescription() publicConvert field description results into abstract schema fields. 
- 
          convertForeignKeyDescription() publicConvert a foreign key description into constraints on the Table object. 
- 
          convertIndexDescription() publicConvert an index description results into abstract schema indexes or constraints. 
- 
          convertOptionsDescription() publicConvert options data into table options. 
- 
          createTableSql() publicGenerate the SQL to create a table. 
- 
          describeColumnSql() publicGenerate the SQL to describe a table. 
- 
          describeForeignKeySql() publicGenerate the SQL to describe the foreign keys in a table. 
- 
          describeIndexSql() publicGenerate the SQL to describe the indexes in a table. 
- 
          describeOptionsSql() publicGenerate the SQL to describe table options 
- 
          dropConstraintSql() publicGenerate the SQL queries needed to drop foreign key constraints from the table 
- 
          dropTableSql() publicGenerate the SQL to drop a table. 
- 
          indexSql() publicGenerate the SQL fragment for a single index in a table. 
- 
          listTablesSql() publicGenerate the SQL to list the tables. 
- 
          truncateTableSql() publicGenerate the SQL to truncate a table. 
Method Detail
__construct() ¶ public
__construct(Cake\Database\Driver $driver)Constructor
This constructor will connect the driver so that methods like columnSql() and others will fail when the driver has not been connected.
Parameters
- 
                Cake\Database\Driver$driver
- The driver to use. 
_convertColumn() ¶ protected
_convertColumn(string $column): arrayConvert a MySQL column type into an abstract type.
The returned type will be a type that Cake\Database\Type can handle.
Parameters
- 
                string$column
- The column type + length 
Returns
arrayArray of column information.
Throws
Cake\Database\ExceptionWhen column type cannot be parsed.
_convertConstraintColumns() ¶ protected
_convertConstraintColumns(string|array $references): stringConvert foreign key constraints references to a valid stringified list
Parameters
- 
                string|array$references
- The referenced columns of a foreign key constraint statement 
Returns
string_convertOnClause() ¶ protected
_convertOnClause(string $clause): string|nullConvert string on clauses to the abstract ones.
Parameters
- 
                string$clause
- The on clause to convert. 
Returns
string|null_foreignOnClause() ¶ protected
_foreignOnClause(string|null $on): stringGenerate an ON clause for a foreign key.
Parameters
- 
                string|null$on
- The on clause 
Returns
string_keySql() ¶ protected
_keySql(string $prefix, array $data): stringHelper method for generating key SQL snippets.
Parameters
- 
                string$prefix
- The key prefix 
- 
                array$data
- Key data. 
Returns
stringaddConstraintSql() ¶ public
addConstraintSql(Cake\Database\Schema\Table $table): arrayGenerate the SQL queries needed to add foreign key constraints to the table
Parameters
- 
                Cake\Database\Schema\Table$table
Returns
arraycolumnSql() ¶ public
columnSql(Cake\Database\Schema\Table $table, string $name): stringGenerate the SQL fragment for a single column in a table.
Parameters
- 
                Cake\Database\Schema\Table$table
- 
                string$name
Returns
stringconstraintSql() ¶ public
constraintSql(Cake\Database\Schema\Table $table, string $name): stringGenerate the SQL fragments for defining table constraints.
Parameters
- 
                Cake\Database\Schema\Table$table
- 
                string$name
Returns
stringconvertColumnDescription() ¶ public
convertColumnDescription(Cake\Database\Schema\Table $table, array $row): voidConvert field description results into abstract schema fields.
Parameters
- 
                Cake\Database\Schema\Table$table
- 
                array$row
Returns
voidconvertForeignKeyDescription() ¶ public
convertForeignKeyDescription(Cake\Database\Schema\Table $table, array $row): voidConvert a foreign key description into constraints on the Table object.
Parameters
- 
                Cake\Database\Schema\Table$table
- 
                array$row
Returns
voidconvertIndexDescription() ¶ public
convertIndexDescription(Cake\Database\Schema\Table $table, array $row): voidConvert an index description results into abstract schema indexes or constraints.
Parameters
- 
                Cake\Database\Schema\Table$table
- 
                array$row
Returns
voidconvertOptionsDescription() ¶ public
convertOptionsDescription(Cake\Database\Schema\Table $table, array $row): voidConvert options data into table options.
Parameters
- 
                Cake\Database\Schema\Table$table
- 
                array$row
Returns
voidcreateTableSql() ¶ public
createTableSql(Cake\Database\Schema\Table $table, array $columns, array $constraints, array $indexes): arrayGenerate the SQL to create a table.
Parameters
- 
                Cake\Database\Schema\Table$table
- 
                array$columns
- 
                array$constraints
- 
                array$indexes
Returns
arraydescribeColumnSql() ¶ public
describeColumnSql(string $tableName, array $config): arrayGenerate the SQL to describe a table.
Parameters
- 
                string$tableName
- 
                array$config
Returns
arraydescribeForeignKeySql() ¶ public
describeForeignKeySql(string $tableName, array $config): arrayGenerate the SQL to describe the foreign keys in a table.
Parameters
- 
                string$tableName
- 
                array$config
Returns
arraydescribeIndexSql() ¶ public
describeIndexSql(string $tableName, array $config): arrayGenerate the SQL to describe the indexes in a table.
Parameters
- 
                string$tableName
- 
                array$config
Returns
arraydescribeOptionsSql() ¶ public
describeOptionsSql(string $tableName, array $config): arrayGenerate the SQL to describe table options
Parameters
- 
                string$tableName
- 
                array$config
Returns
arraydropConstraintSql() ¶ public
dropConstraintSql(Cake\Database\Schema\Table $table): arrayGenerate the SQL queries needed to drop foreign key constraints from the table
Parameters
- 
                Cake\Database\Schema\Table$table
Returns
arraydropTableSql() ¶ public
dropTableSql(Cake\Database\Schema\Table $table): arrayGenerate the SQL to drop a table.
Parameters
- 
                Cake\Database\Schema\Table$table
- Table instance 
Returns
arraySQL statements to drop a table.
indexSql() ¶ public
indexSql(Cake\Database\Schema\Table $table, string $name): stringGenerate the SQL fragment for a single index in a table.
Parameters
- 
                Cake\Database\Schema\Table$table
- 
                string$name
Returns
stringlistTablesSql() ¶ public
listTablesSql(array $config): arrayGenerate the SQL to list the tables.
Parameters
- 
                array$config
Returns
arraytruncateTableSql() ¶ public
truncateTableSql(Cake\Database\Schema\Table $table): arrayGenerate the SQL to truncate a table.
Parameters
- 
                Cake\Database\Schema\Table$table
Returns
array