Properties

$commands

$commands : array

Type

array

Methods

__construct()

__construct(\Phinx\Db\Adapter\AdapterInterface  $adapter) 

Class constructor, must always wrap another adapter.

Parameters

\Phinx\Db\Adapter\AdapterInterface $adapter

setOptions()

setOptions(array  $options) : \Phinx\Db\Adapter\AdapterInterface

Set adapter configuration options.

Parameters

array $options

Returns

\Phinx\Db\Adapter\AdapterInterface

getOptions()

getOptions() : array

Get all adapter options.

Returns

array

hasOption()

hasOption(string  $name) : boolean

Check if an option has been set.

Parameters

string $name

Returns

boolean

getOption()

getOption(string  $name) : mixed

Get a single adapter option, or null if the option does not exist.

Parameters

string $name

Returns

mixed

connect()

connect() : void

Initializes the database connection.

disconnect()

disconnect() : void

Closes the database connection.

execute()

execute(string  $sql) : integer

Executes a SQL statement and returns the number of affected rows.

Parameters

string $sql

SQL

Returns

integer

query()

query(string  $sql) : array

Executes a SQL statement and returns the result as an array.

Parameters

string $sql

SQL

Returns

array

insert()

insert(\Phinx\Db\Table  $table, array  $row) : void

Inserts data into a table.

Parameters

\Phinx\Db\Table $table

where to insert data

array $row

fetchRow()

fetchRow(string  $sql) : array

Executes a query and returns only one row as an array.

Parameters

string $sql

SQL

Returns

array

fetchAll()

fetchAll(string  $sql) : array

Executes a query and returns an array of rows.

Parameters

string $sql

SQL

Returns

array

getVersions()

getVersions() : array

Get all migrated version numbers.

Returns

array

getVersionLog()

getVersionLog() : array

Get all migration log entries, indexed by version number.

Returns

array

migrated()

migrated(\Phinx\Migration\MigrationInterface  $migration, string  $direction, integer  $startTime, integer  $endTime) : \Phinx\Db\Adapter\AdapterInterface

Records a migration being run.

Parameters

\Phinx\Migration\MigrationInterface $migration

Migration

string $direction

Direction

integer $startTime

Start Time

integer $endTime

End Time

Returns

\Phinx\Db\Adapter\AdapterInterface

resetAllBreakpoints()

resetAllBreakpoints() : integer

Reset all migration breakpoints.

Returns

integer —

The number of breakpoints reset

hasSchemaTable()

hasSchemaTable() : boolean

Does the schema table exist?

Returns

boolean

createSchemaTable()

createSchemaTable() : void

Creates the schema table.

getColumnTypes()

getColumnTypes() : array

Returns an array of the supported Phinx column types.

Returns

array

isValidColumnType()

isValidColumnType(\Phinx\Db\Table\Column  $column) : boolean

Checks that the given column is of a supported type.

Parameters

\Phinx\Db\Table\Column $column

Returns

boolean

hasTransactions()

hasTransactions() : boolean

Does the adapter support transactions?

Returns

boolean

beginTransaction()

beginTransaction() : void

Begin a transaction.

commitTransaction()

commitTransaction() : void

Commit a transaction.

rollbackTransaction()

rollbackTransaction() : void

Rollback a transaction.

quoteTableName()

quoteTableName(string  $tableName) : string

Quotes a table name for use in a query.

Parameters

string $tableName

Table Name

Returns

string

quoteColumnName()

quoteColumnName(string  $columnName) : string

Quotes a column name for use in a query.

Parameters

string $columnName

Table Name

Returns

string

hasTable()

hasTable(string  $tableName) : boolean

Checks to see if a table exists.

Parameters

string $tableName

Table Name

Returns

boolean

createTable()

createTable(\Phinx\Db\Table  $table) : void

Creates the specified database table.

Parameters

\Phinx\Db\Table $table

Table

renameTable()

renameTable(string  $tableName,   $newTableName) : void

Renames the specified database table.

Parameters

string $tableName

Table Name

$newTableName

dropTable()

dropTable(string  $tableName) : void

Drops the specified database table.

Parameters

string $tableName

Table Name

getColumns()

getColumns(string  $tableName) : array<mixed,\Phinx\Db\Table\Column>

Returns table columns

Parameters

string $tableName

Table Name

Returns

array<mixed,\Phinx\Db\Table\Column>

hasColumn()

hasColumn(string  $tableName, string  $columnName) : boolean

Checks to see if a column exists.

Parameters

string $tableName

Table Name

string $columnName

Column Name

Returns

boolean

addColumn()

addColumn(\Phinx\Db\Table  $table, \Phinx\Db\Table\Column  $column) : void

Adds the specified column to a database table.

Parameters

\Phinx\Db\Table $table

Table

\Phinx\Db\Table\Column $column

Column

renameColumn()

renameColumn(string  $tableName, string  $columnName, string  $newColumnName) : void

Renames the specified column.

Parameters

string $tableName

Table Name

string $columnName

Column Name

string $newColumnName

New Column Name

changeColumn()

changeColumn(string  $tableName, string  $columnName, \Phinx\Db\Table\Column  $newColumn) : \Phinx\Db\Table

Change a table column type.

Parameters

string $tableName

Table Name

string $columnName

Column Name

\Phinx\Db\Table\Column $newColumn

New Column

Returns

\Phinx\Db\Table

dropColumn()

dropColumn(string  $tableName, string  $columnName) : void

Drops the specified column.

Parameters

string $tableName

Table Name

string $columnName

Column Name

hasIndex()

hasIndex(string  $tableName, mixed  $columns) : boolean

Checks to see if an index exists.

Parameters

string $tableName

Table Name

mixed $columns

Column(s)

Returns

boolean

hasIndexByName()

hasIndexByName(string  $tableName, string  $indexName) : boolean

Checks to see if an index specified by name exists.

Parameters

string $tableName

Table Name

string $indexName

Returns

boolean

addIndex()

addIndex(\Phinx\Db\Table  $table, \Phinx\Db\Table\Index  $index) : void

Adds the specified index to a database table.

Parameters

\Phinx\Db\Table $table

Table

\Phinx\Db\Table\Index $index

Index

dropIndex()

dropIndex(string  $tableName, mixed  $columns,   $options = array()) : void

Drops the specified index from a database table.

Parameters

string $tableName
mixed $columns

Column(s)

$options

dropIndexByName()

dropIndexByName(string  $tableName, string  $indexName) : void

Drops the index specified by name from a database table.

Parameters

string $tableName
string $indexName

hasForeignKey()

hasForeignKey(string  $tableName, array<mixed,string>  $columns, string  $constraint = null) : boolean

Checks to see if a foreign key exists.

Parameters

string $tableName
array<mixed,string> $columns

Column(s)

string $constraint

Constraint name

Returns

boolean

addForeignKey()

addForeignKey(\Phinx\Db\Table  $table, \Phinx\Db\Table\ForeignKey  $foreignKey) : void

Adds the specified foreign key to a database table.

Parameters

\Phinx\Db\Table $table
\Phinx\Db\Table\ForeignKey $foreignKey

dropForeignKey()

dropForeignKey(string  $tableName, array<mixed,string>  $columns, string  $constraint = null) : void

Drops the specified foreign key from a database table.

Parameters

string $tableName
array<mixed,string> $columns

Column(s)

string $constraint

Constraint name

getSqlType()

getSqlType(string  $type, integer  $limit = null) : string

Converts the Phinx logical type to the adapter's SQL type.

Parameters

string $type
integer $limit

Returns

string

createDatabase()

createDatabase(string  $name, array  $options = array()) : void

Creates a new database.

Parameters

string $name

Database Name

array $options

Options

hasDatabase()

hasDatabase(string  $name) : boolean

Checks to see if a database exists.

Parameters

string $name

Database Name

Returns

boolean

dropDatabase()

dropDatabase(string  $name) : void

Drops the specified database.

Parameters

string $name

Database Name

castToBool()

castToBool(  $value) 

Parameters

$value

getAdapterType()

getAdapterType() 

{@inheritdoc}

recordCommand()

recordCommand(string  $name, array  $arguments) : void

Record a command for execution later.

Parameters

string $name

Command Name

array $arguments

Command Arguments

setCommands()

setCommands(array  $commands) : \Phinx\Db\Adapter\ProxyAdapter

Sets an array of recorded commands.

Parameters

array $commands

Commands

Returns

\Phinx\Db\Adapter\ProxyAdapter

getCommands()

getCommands() : array

Gets an array of the recorded commands.

Returns

array

getInvertedCommands()

getInvertedCommands() : array

Gets an array of the recorded commands in reverse.

Throws

\Phinx\Migration\IrreversibleMigrationException

if a command cannot be reversed.

Returns

array

executeCommands()

executeCommands() : void

Execute the recorded commands.

executeInvertedCommands()

executeInvertedCommands() : void

Execute the recorded commands in reverse.

invertCreateTable()

invertCreateTable(array  $args) : array

Returns the reverse of a createTable command.

Parameters

array $args

Method Arguments

Returns

array

invertRenameTable()

invertRenameTable(array  $args) : array

Returns the reverse of a renameTable command.

Parameters

array $args

Method Arguments

Returns

array

invertAddColumn()

invertAddColumn(array  $args) : array

Returns the reverse of a addColumn command.

Parameters

array $args

Method Arguments

Returns

array

invertRenameColumn()

invertRenameColumn(array  $args) : array

Returns the reverse of a renameColumn command.

Parameters

array $args

Method Arguments

Returns

array

invertAddIndex()

invertAddIndex(array  $args) : array

Returns the reverse of a addIndex command.

Parameters

array $args

Method Arguments

Returns

array

invertAddForeignKey()

invertAddForeignKey(array  $args) : array

Returns the reverse of a addForeignKey command.

Parameters

array $args

Method Arguments

Returns

array