Constants

PHINX_TYPE_STRING

PHINX_TYPE_STRING = 'string'

PHINX_TYPE_CHAR

PHINX_TYPE_CHAR = 'char'

PHINX_TYPE_TEXT

PHINX_TYPE_TEXT = 'text'

PHINX_TYPE_INTEGER

PHINX_TYPE_INTEGER = 'integer'

PHINX_TYPE_BIG_INTEGER

PHINX_TYPE_BIG_INTEGER = 'biginteger'

PHINX_TYPE_FLOAT

PHINX_TYPE_FLOAT = 'float'

PHINX_TYPE_DECIMAL

PHINX_TYPE_DECIMAL = 'decimal'

PHINX_TYPE_DATETIME

PHINX_TYPE_DATETIME = 'datetime'

PHINX_TYPE_TIMESTAMP

PHINX_TYPE_TIMESTAMP = 'timestamp'

PHINX_TYPE_TIME

PHINX_TYPE_TIME = 'time'

PHINX_TYPE_DATE

PHINX_TYPE_DATE = 'date'

PHINX_TYPE_BINARY

PHINX_TYPE_BINARY = 'binary'

PHINX_TYPE_VARBINARY

PHINX_TYPE_VARBINARY = 'varbinary'

PHINX_TYPE_BLOB

PHINX_TYPE_BLOB = 'blob'

PHINX_TYPE_BOOLEAN

PHINX_TYPE_BOOLEAN = 'boolean'

PHINX_TYPE_JSON

PHINX_TYPE_JSON = 'json'

PHINX_TYPE_JSONB

PHINX_TYPE_JSONB = 'jsonb'

PHINX_TYPE_UUID

PHINX_TYPE_UUID = 'uuid'

PHINX_TYPE_FILESTREAM

PHINX_TYPE_FILESTREAM = 'filestream'

PHINX_TYPE_GEOMETRY

PHINX_TYPE_GEOMETRY = 'geometry'

PHINX_TYPE_POINT

PHINX_TYPE_POINT = 'point'

PHINX_TYPE_LINESTRING

PHINX_TYPE_LINESTRING = 'linestring'

PHINX_TYPE_POLYGON

PHINX_TYPE_POLYGON = 'polygon'

PHINX_TYPE_ENUM

PHINX_TYPE_ENUM = 'enum'

PHINX_TYPE_SET

PHINX_TYPE_SET = 'set'

Methods

getVersions()

getVersions() : array

Get all migrated version numbers.

Returns

array

getVersionLog()

getVersionLog() : array

Get all migration log entries, indexed by version number.

Returns

array

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

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.

getAdapterType()

getAdapterType() : string

Returns the adapter type.

Returns

string

connect()

connect() : void

Initializes the database connection.

Throws

\RuntimeException

When the requested database driver is not installed.

disconnect()

disconnect() : void

Closes the database connection.

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.

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

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

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

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, string  $newName) : void

Renames the specified database table.

Parameters

string $tableName

Table Name

string $newName

New Name

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) : void

Drops the specified index from a database table.

Parameters

string $tableName
mixed $columns

Column(s)

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

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

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