PHP Класс Migrations\CakeAdapter

Наследование: implements Phinx\Db\Adapter\AdapterInterface
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$adapter Phinx\Db\Adapter\AdapterInterface Decorated adapter
$connection Cake\Database\Connection Database connection

Открытые методы

Метод Описание
__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.

Описание методов

__construct() публичный Метод

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() публичный Метод

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
Результат void

addForeignKey() публичный Метод

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
Результат void

addIndex() публичный Метод

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
Результат void

beginTransaction() публичный Метод

Begin a transaction.
public beginTransaction ( ) : void
Результат void

changeColumn() публичный Метод

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
Результат Phinx\Db\Table

commitTransaction() публичный Метод

Commit a transaction.
public commitTransaction ( ) : void
Результат void

connect() публичный Метод

Initializes the database connection.
public connect ( ) : void
Результат void

createDatabase() публичный Метод

Creates a new database.
public createDatabase ( string $name, array $options = [] ) : void
$name string Database Name
$options array Options
Результат void

createSchemaTable() публичный Метод

Creates the schema table.
public createSchemaTable ( ) : void
Результат void

createTable() публичный Метод

Creates the specified database table.
public createTable ( Phinx\Db\Table $table ) : void
$table Phinx\Db\Table Table
Результат void

disconnect() публичный Метод

Closes the database connection.
public disconnect ( ) : void
Результат void

dropColumn() публичный Метод

Drops the specified column.
public dropColumn ( string $tableName, string $columnName ) : void
$tableName string Table Name
$columnName string Column Name
Результат void

dropDatabase() публичный Метод

Drops the specified database.
public dropDatabase ( string $name ) : void
$name string Database Name
Результат void

dropForeignKey() публичный Метод

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
Результат void

dropIndex() публичный Метод

Drops the specified index from a database table.
public dropIndex ( string $tableName, mixed $columns ) : void
$tableName string
$columns mixed Column(s)
Результат void

dropIndexByName() публичный Метод

Drops the index specified by name from a database table.
public dropIndexByName ( string $tableName, string $indexName ) : void
$tableName string
$indexName string
Результат void

dropTable() публичный Метод

Drops the specified database table.
public dropTable ( string $tableName ) : void
$tableName string Table Name
Результат void

endCommandTimer() публичный Метод

Stop timing the current command and write the elapsed time to the output.
public endCommandTimer ( ) : void
Результат void

execute() публичный Метод

Executes a SQL statement and returns the number of affected rows.
public execute ( string $sql ) : integer
$sql string SQL
Результат integer

fetchAll() публичный Метод

Executes a query and returns an array of rows.
public fetchAll ( string $sql ) : array
$sql string SQL
Результат array

fetchRow() публичный Метод

Executes a query and returns only one row as an array.
public fetchRow ( string $sql ) : array
$sql string SQL
Результат array

getAdapterType() публичный Метод

Returns the adapter type.
public getAdapterType ( ) : string
Результат string

getColumnTypes() публичный Метод

Returns an array of the supported Phinx column types.
public getColumnTypes ( ) : array
Результат array

getColumns() публичный Метод

Returns table columns
public getColumns ( string $tableName ) : Phinx\Db\Table\Column[]
$tableName string Table Name
Результат Phinx\Db\Table\Column[]

getCommandStartTime() публичный Метод

Gets the command start time
public getCommandStartTime ( ) : integer
Результат integer

getConnection() публичный Метод

Gets the database connection
public getConnection ( ) : PDO
Результат PDO

getOption() публичный Метод

Get a single adapter option, or null if the option does not exist.
public getOption ( string $name ) : mixed
$name string
Результат mixed

getOptions() публичный Метод

Get all adapter options.
public getOptions ( ) : array
Результат array

getOutput() публичный Метод

Gets the console output.
public getOutput ( ) : Symfony\Component\Console\Output\OutputInterface
Результат Symfony\Component\Console\Output\OutputInterface

getSqlType() публичный Метод

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
Результат string

getVersionLog() публичный Метод

Get all migration log entries, indexed by version number.
public getVersionLog ( ) : array
Результат array

getVersions() публичный Метод

Get all migrated version numbers.
public getVersions ( ) : array
Результат array

hasColumn() публичный Метод

Checks to see if a column exists.
public hasColumn ( string $tableName, string $columnName ) : boolean
$tableName string Table Name
$columnName string Column Name
Результат boolean

hasDatabase() публичный Метод

Checks to see if a database exists.
public hasDatabase ( string $name ) : boolean
$name string Database Name
Результат boolean

hasForeignKey() публичный Метод

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
Результат boolean

hasIndex() публичный Метод

Checks to see if an index exists.
public hasIndex ( string $tableName, mixed $columns ) : boolean
$tableName string Table Name
$columns mixed Column(s)
Результат boolean

hasIndexByName() публичный Метод

Checks to see if an index specified by name exists.
public hasIndexByName ( string $tableName, string $indexName ) : boolean
$tableName string Table Name
$indexName string
Результат boolean

hasOption() публичный Метод

Check if an option has been set.
public hasOption ( string $name ) : boolean
$name string
Результат boolean

hasSchemaTable() публичный Метод

Does the schema table exist?
Устаревший: use hasTable instead.
public hasSchemaTable ( ) : boolean
Результат boolean

hasTable() публичный Метод

Checks to see if a table exists.
public hasTable ( string $tableName ) : boolean
$tableName string Table Name
Результат boolean

hasTransactions() публичный Метод

Does the adapter support transactions?
public hasTransactions ( ) : boolean
Результат boolean

insert() публичный Метод

Inserts data into a table.
public insert ( Phinx\Db\Table $table, array $row ) : void
$table Phinx\Db\Table where to insert data
$row array
Результат void

isValidColumnType() публичный Метод

Checks that the given column is of a supported type.
public isValidColumnType ( Phinx\Db\Table\Column $column ) : boolean
$column Phinx\Db\Table\Column
Результат boolean

migrated() публичный Метод

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
Результат Phinx\Db\Adapter\AdapterInterface

query() публичный Метод

Executes a SQL statement and returns the result as an array.
public query ( string $sql ) : array
$sql string SQL
Результат array

quoteColumnName() публичный Метод

Quotes a column name for use in a query.
public quoteColumnName ( string $columnName ) : string
$columnName string Table Name
Результат string

quoteTableName() публичный Метод

Quotes a table name for use in a query.
public quoteTableName ( string $tableName ) : string
$tableName string Table Name
Результат string

renameColumn() публичный Метод

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
Результат void

renameTable() публичный Метод

Renames the specified database table.
public renameTable ( string $tableName, string $newName ) : void
$tableName string Table Name
$newName string New Name
Результат void

rollbackTransaction() публичный Метод

Rollback a transaction.
public rollbackTransaction ( ) : void
Результат void

setCommandStartTime() публичный Метод

Sets the command start time
public setCommandStartTime ( integer $time ) : Phinx\Db\Adapter\AdapterInterface
$time integer
Результат Phinx\Db\Adapter\AdapterInterface

setOptions() публичный Метод

Set adapter configuration options.
public setOptions ( array $options ) : Phinx\Db\Adapter\AdapterInterface
$options array
Результат Phinx\Db\Adapter\AdapterInterface

setOutput() публичный Метод

Sets the console output.
public setOutput ( Symfony\Component\Console\Output\OutputInterface $output ) : Phinx\Db\Adapter\AdapterInterface
$output Symfony\Component\Console\Output\OutputInterface Output
Результат Phinx\Db\Adapter\AdapterInterface

startCommandTimer() публичный Метод

Start timing a command.
public startCommandTimer ( ) : void
Результат void

writeCommand() публичный Метод

Write a Phinx command to the output.
public writeCommand ( string $command, array $args = [] ) : void
$command string Command Name
$args array Command Args
Результат void

Описание свойств

$adapter защищенное свойство

Decorated adapter
protected AdapterInterface,Phinx\Db\Adapter $adapter
Результат Phinx\Db\Adapter\AdapterInterface

$connection защищенное свойство

Database connection
protected Connection,Cake\Database $connection
Результат Cake\Database\Connection