PHP Class Migrations\CakeAdapter

Inheritance: implements Phinx\Db\Adapter\AdapterInterface
Afficher le fichier Open project: cakephp/migrations

Protected Properties

Свойство Type Description
$adapter Phinx\Db\Adapter\AdapterInterface Decorated adapter
$connection Cake\Database\Connection Database connection

Méthodes publiques

Méthode Description
__construct ( Phinx\Db\Adapter\AdapterInterface $adapter, Connection $connection ) Constructor
addColumn ( Phinx\Db\Table $table, Phinx\Db\Table\Column $column ) : void Adds the specified column to a database table.
addForeignKey ( Phinx\Db\Table $table, Phinx\Db\Table\ForeignKey $foreignKey ) : void Adds the specified foreign key to a database table.
addIndex ( Phinx\Db\Table $table, Phinx\Db\Table\Index $index ) : void Adds the specified index to a database table.
beginTransaction ( ) : void Begin a transaction.
changeColumn ( string $tableName, string $columnName, Phinx\Db\Table\Column $newColumn ) : Phinx\Db\Table Change a table column type.
commitTransaction ( ) : void Commit a transaction.
connect ( ) : void Initializes the database connection.
createDatabase ( string $name, array $options = [] ) : void Creates a new database.
createSchemaTable ( ) : void Creates the schema table.
createTable ( Phinx\Db\Table $table ) : void Creates the specified database table.
disconnect ( ) : void Closes the database connection.
dropColumn ( string $tableName, string $columnName ) : void Drops the specified column.
dropDatabase ( string $name ) : void Drops the specified database.
dropForeignKey ( string $tableName, string[] $columns, string | null $constraint = null ) : void Drops the specified foreign key from a database table.
dropIndex ( string $tableName, mixed $columns ) : void Drops the specified index from a database table.
dropIndexByName ( string $tableName, string $indexName ) : void Drops the index specified by name from a database table.
dropTable ( string $tableName ) : void Drops the specified database table.
endCommandTimer ( ) : void Stop timing the current command and write the elapsed time to the output.
execute ( string $sql ) : integer Executes a SQL statement and returns the number of affected rows.
fetchAll ( string $sql ) : array Executes a query and returns an array of rows.
fetchRow ( string $sql ) : array Executes a query and returns only one row as an array.
getAdapterType ( ) : string Returns the adapter type.
getColumnTypes ( ) : array Returns an array of the supported Phinx column types.
getColumns ( string $tableName ) : Phinx\Db\Table\Column[] Returns table columns
getCommandStartTime ( ) : integer Gets the command start time
getConnection ( ) : PDO Gets the database connection
getOption ( string $name ) : mixed Get a single adapter option, or null if the option does not exist.
getOptions ( ) : array Get all adapter options.
getOutput ( ) : Symfony\Component\Console\Output\OutputInterface Gets the console output.
getSqlType ( string $type, integer | null $limit = null ) : string Converts the Phinx logical type to the adapter's SQL type.
getVersionLog ( ) : array Get all migration log entries, indexed by version number.
getVersions ( ) : array Get all migrated version numbers.
hasColumn ( string $tableName, string $columnName ) : boolean Checks to see if a column exists.
hasDatabase ( string $name ) : boolean Checks to see if a database exists.
hasForeignKey ( string $tableName, string[] $columns, string | null $constraint = null ) : boolean Checks to see if a foreign key exists.
hasIndex ( string $tableName, mixed $columns ) : boolean Checks to see if an index exists.
hasIndexByName ( string $tableName, string $indexName ) : boolean Checks to see if an index specified by name exists.
hasOption ( string $name ) : boolean Check if an option has been set.
hasSchemaTable ( ) : boolean Does the schema table exist?
hasTable ( string $tableName ) : boolean Checks to see if a table exists.
hasTransactions ( ) : boolean Does the adapter support transactions?
insert ( Phinx\Db\Table $table, array $row ) : void Inserts data into a table.
isValidColumnType ( Phinx\Db\Table\Column $column ) : boolean Checks that the given column is of a supported type.
migrated ( Phinx\Migration\MigrationInterface $migration, string $direction, integer $startTime, integer $endTime ) : Phinx\Db\Adapter\AdapterInterface Records a migration being run.
query ( string $sql ) : array Executes a SQL statement and returns the result as an array.
quoteColumnName ( string $columnName ) : string Quotes a column name for use in a query.
quoteTableName ( string $tableName ) : string Quotes a table name for use in a query.
renameColumn ( string $tableName, string $columnName, string $newColumnName ) : void Renames the specified column.
renameTable ( string $tableName, string $newName ) : void Renames the specified database table.
rollbackTransaction ( ) : void Rollback a transaction.
setCommandStartTime ( integer $time ) : Phinx\Db\Adapter\AdapterInterface Sets the command start time
setOptions ( array $options ) : Phinx\Db\Adapter\AdapterInterface Set adapter configuration options.
setOutput ( Symfony\Component\Console\Output\OutputInterface $output ) : Phinx\Db\Adapter\AdapterInterface Sets the console output.
startCommandTimer ( ) : void Start timing a command.
writeCommand ( string $command, array $args = [] ) : void Write a Phinx command to the output.

Method Details

__construct() public méthode

Constructor
public __construct ( Phinx\Db\Adapter\AdapterInterface $adapter, Connection $connection )
$adapter Phinx\Db\Adapter\AdapterInterface The original adapter to decorate.
$connection Cake\Database\Connection The connection to actually use.

addColumn() public méthode

Adds the specified column to a database table.
public addColumn ( Phinx\Db\Table $table, Phinx\Db\Table\Column $column ) : void
$table Phinx\Db\Table Table
$column Phinx\Db\Table\Column Column
Résultat void

addForeignKey() public méthode

Adds the specified foreign key to a database table.
public addForeignKey ( Phinx\Db\Table $table, Phinx\Db\Table\ForeignKey $foreignKey ) : void
$table Phinx\Db\Table
$foreignKey Phinx\Db\Table\ForeignKey
Résultat void

addIndex() public méthode

Adds the specified index to a database table.
public addIndex ( Phinx\Db\Table $table, Phinx\Db\Table\Index $index ) : void
$table Phinx\Db\Table Table
$index Phinx\Db\Table\Index Index
Résultat void

beginTransaction() public méthode

Begin a transaction.
public beginTransaction ( ) : void
Résultat void

changeColumn() public méthode

Change a table column type.
public changeColumn ( string $tableName, string $columnName, Phinx\Db\Table\Column $newColumn ) : Phinx\Db\Table
$tableName string Table Name
$columnName string Column Name
$newColumn Phinx\Db\Table\Column New Column
Résultat Phinx\Db\Table

commitTransaction() public méthode

Commit a transaction.
public commitTransaction ( ) : void
Résultat void

connect() public méthode

Initializes the database connection.
public connect ( ) : void
Résultat void

createDatabase() public méthode

Creates a new database.
public createDatabase ( string $name, array $options = [] ) : void
$name string Database Name
$options array Options
Résultat void

createSchemaTable() public méthode

Creates the schema table.
public createSchemaTable ( ) : void
Résultat void

createTable() public méthode

Creates the specified database table.
public createTable ( Phinx\Db\Table $table ) : void
$table Phinx\Db\Table Table
Résultat void

disconnect() public méthode

Closes the database connection.
public disconnect ( ) : void
Résultat void

dropColumn() public méthode

Drops the specified column.
public dropColumn ( string $tableName, string $columnName ) : void
$tableName string Table Name
$columnName string Column Name
Résultat void

dropDatabase() public méthode

Drops the specified database.
public dropDatabase ( string $name ) : void
$name string Database Name
Résultat void

dropForeignKey() public méthode

If the adapter property is an instance of the \Phinx\Db\Adapter\SQLiteAdapter, a specific method will be called. The original one from Phinx contains a bug that can drop a table in certain conditions.
public dropForeignKey ( string $tableName, string[] $columns, string | null $constraint = null ) : void
$tableName string
$columns string[] Column(s)
$constraint string | null Constraint name
Résultat void

dropIndex() public méthode

Drops the specified index from a database table.
public dropIndex ( string $tableName, mixed $columns ) : void
$tableName string
$columns mixed Column(s)
Résultat void

dropIndexByName() public méthode

Drops the index specified by name from a database table.
public dropIndexByName ( string $tableName, string $indexName ) : void
$tableName string
$indexName string
Résultat void

dropTable() public méthode

Drops the specified database table.
public dropTable ( string $tableName ) : void
$tableName string Table Name
Résultat void

endCommandTimer() public méthode

Stop timing the current command and write the elapsed time to the output.
public endCommandTimer ( ) : void
Résultat void

execute() public méthode

Executes a SQL statement and returns the number of affected rows.
public execute ( string $sql ) : integer
$sql string SQL
Résultat integer

fetchAll() public méthode

Executes a query and returns an array of rows.
public fetchAll ( string $sql ) : array
$sql string SQL
Résultat array

fetchRow() public méthode

Executes a query and returns only one row as an array.
public fetchRow ( string $sql ) : array
$sql string SQL
Résultat array

getAdapterType() public méthode

Returns the adapter type.
public getAdapterType ( ) : string
Résultat string

getColumnTypes() public méthode

Returns an array of the supported Phinx column types.
public getColumnTypes ( ) : array
Résultat array

getColumns() public méthode

Returns table columns
public getColumns ( string $tableName ) : Phinx\Db\Table\Column[]
$tableName string Table Name
Résultat Phinx\Db\Table\Column[]

getCommandStartTime() public méthode

Gets the command start time
public getCommandStartTime ( ) : integer
Résultat integer

getConnection() public méthode

Gets the database connection
public getConnection ( ) : PDO
Résultat PDO

getOption() public méthode

Get a single adapter option, or null if the option does not exist.
public getOption ( string $name ) : mixed
$name string
Résultat mixed

getOptions() public méthode

Get all adapter options.
public getOptions ( ) : array
Résultat array

getOutput() public méthode

Gets the console output.
public getOutput ( ) : Symfony\Component\Console\Output\OutputInterface
Résultat Symfony\Component\Console\Output\OutputInterface

getSqlType() public méthode

Converts the Phinx logical type to the adapter's SQL type.
public getSqlType ( string $type, integer | null $limit = null ) : string
$type string
$limit integer | null
Résultat string

getVersionLog() public méthode

Get all migration log entries, indexed by version number.
public getVersionLog ( ) : array
Résultat array

getVersions() public méthode

Get all migrated version numbers.
public getVersions ( ) : array
Résultat array

hasColumn() public méthode

Checks to see if a column exists.
public hasColumn ( string $tableName, string $columnName ) : boolean
$tableName string Table Name
$columnName string Column Name
Résultat boolean

hasDatabase() public méthode

Checks to see if a database exists.
public hasDatabase ( string $name ) : boolean
$name string Database Name
Résultat boolean

hasForeignKey() public méthode

Checks to see if a foreign key exists.
public hasForeignKey ( string $tableName, string[] $columns, string | null $constraint = null ) : boolean
$tableName string
$columns string[] Column(s)
$constraint string | null Constraint name
Résultat boolean

hasIndex() public méthode

Checks to see if an index exists.
public hasIndex ( string $tableName, mixed $columns ) : boolean
$tableName string Table Name
$columns mixed Column(s)
Résultat boolean

hasIndexByName() public méthode

Checks to see if an index specified by name exists.
public hasIndexByName ( string $tableName, string $indexName ) : boolean
$tableName string Table Name
$indexName string
Résultat boolean

hasOption() public méthode

Check if an option has been set.
public hasOption ( string $name ) : boolean
$name string
Résultat boolean

hasSchemaTable() public méthode

Does the schema table exist?
Deprecation: use hasTable instead.
public hasSchemaTable ( ) : boolean
Résultat boolean

hasTable() public méthode

Checks to see if a table exists.
public hasTable ( string $tableName ) : boolean
$tableName string Table Name
Résultat boolean

hasTransactions() public méthode

Does the adapter support transactions?
public hasTransactions ( ) : boolean
Résultat boolean

insert() public méthode

Inserts data into a table.
public insert ( Phinx\Db\Table $table, array $row ) : void
$table Phinx\Db\Table where to insert data
$row array
Résultat void

isValidColumnType() public méthode

Checks that the given column is of a supported type.
public isValidColumnType ( Phinx\Db\Table\Column $column ) : boolean
$column Phinx\Db\Table\Column
Résultat boolean

migrated() public méthode

Records a migration being run.
public migrated ( Phinx\Migration\MigrationInterface $migration, string $direction, integer $startTime, integer $endTime ) : Phinx\Db\Adapter\AdapterInterface
$migration Phinx\Migration\MigrationInterface Migration
$direction string Direction
$startTime integer Start Time
$endTime integer End Time
Résultat Phinx\Db\Adapter\AdapterInterface

query() public méthode

Executes a SQL statement and returns the result as an array.
public query ( string $sql ) : array
$sql string SQL
Résultat array

quoteColumnName() public méthode

Quotes a column name for use in a query.
public quoteColumnName ( string $columnName ) : string
$columnName string Table Name
Résultat string

quoteTableName() public méthode

Quotes a table name for use in a query.
public quoteTableName ( string $tableName ) : string
$tableName string Table Name
Résultat string

renameColumn() public méthode

Renames the specified column.
public renameColumn ( string $tableName, string $columnName, string $newColumnName ) : void
$tableName string Table Name
$columnName string Column Name
$newColumnName string New Column Name
Résultat void

renameTable() public méthode

Renames the specified database table.
public renameTable ( string $tableName, string $newName ) : void
$tableName string Table Name
$newName string New Name
Résultat void

rollbackTransaction() public méthode

Rollback a transaction.
public rollbackTransaction ( ) : void
Résultat void

setCommandStartTime() public méthode

Sets the command start time
public setCommandStartTime ( integer $time ) : Phinx\Db\Adapter\AdapterInterface
$time integer
Résultat Phinx\Db\Adapter\AdapterInterface

setOptions() public méthode

Set adapter configuration options.
public setOptions ( array $options ) : Phinx\Db\Adapter\AdapterInterface
$options array
Résultat Phinx\Db\Adapter\AdapterInterface

setOutput() public méthode

Sets the console output.
public setOutput ( Symfony\Component\Console\Output\OutputInterface $output ) : Phinx\Db\Adapter\AdapterInterface
$output Symfony\Component\Console\Output\OutputInterface Output
Résultat Phinx\Db\Adapter\AdapterInterface

startCommandTimer() public méthode

Start timing a command.
public startCommandTimer ( ) : void
Résultat void

writeCommand() public méthode

Write a Phinx command to the output.
public writeCommand ( string $command, array $args = [] ) : void
$command string Command Name
$args array Command Args
Résultat void

Property Details

$adapter protected_oe property

Decorated adapter
protected AdapterInterface,Phinx\Db\Adapter $adapter
Résultat Phinx\Db\Adapter\AdapterInterface

$connection protected_oe property

Database connection
protected Connection,Cake\Database $connection
Résultat Cake\Database\Connection