\Phinx\MigrationAbstractMigration

Abstract Migration Class.

It is expected that the migrations you write extend from this class.

This abstract class proxies the various database methods to your specified adapter.

Summary

Methods
Properties
Constants
__construct()
up()
down()
setAdapter()
getAdapter()
setInput()
getInput()
setOutput()
getOutput()
getName()
setVersion()
getVersion()
execute()
query()
fetchRow()
fetchAll()
insert()
createDatabase()
dropDatabase()
hasTable()
table()
dropTable()
No public properties found
No constants found
init()
$version
$adapter
$output
$input
N/A
No private methods found
No private properties found
N/A

Properties

$version

$version : float

Type

float

Methods

__construct()

__construct(integer  $version, \think\console\Input|null  $input = null, \think\console\Output|null  $output = null) 

Class Constructor.

Parameters

integer $version

Migration Version

\think\console\Input|null $input
\think\console\Output|null $output

up()

up() : void

Migrate Up

down()

down() : void

Migrate Down

getInput()

getInput() : \think\console\Input

Gets the input object to be used in migration object

Returns

\think\console\Input

getOutput()

getOutput() : \think\console\Output

Gets the output object to be used in migration object

Returns

\think\console\Output

getName()

getName() : string

Gets the name.

Returns

string

setVersion()

setVersion(float  $version) : \Phinx\Migration\MigrationInterface

Sets the migration version number.

Parameters

float $version

Version

Returns

\Phinx\Migration\MigrationInterface

getVersion()

getVersion() : float

Gets the migration version number.

Returns

float

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(  $table, array  $data) : void

Insert data into a table.

Parameters

$table
array $data

createDatabase()

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

Create a new database.

Parameters

string $name

Database Name

array $options

Options

dropDatabase()

dropDatabase(string  $name) : void

Drop a database.

Parameters

string $name

Database Name

hasTable()

hasTable(string  $tableName) : boolean

Checks to see if a table exists.

Parameters

string $tableName

Table Name

Returns

boolean

table()

table(string  $tableName, array  $options = array()) : \Phinx\Db\Table

Returns an instance of the <code>\Table</code> class.

You can use this class to create and manipulate tables.

Parameters

string $tableName

Table Name

array $options

Options

Returns

\Phinx\Db\Table

dropTable()

dropTable(string  $tableName) : void

A short-hand method to drop the given database table.

Parameters

string $tableName

Table Name

init()

init() : void

Initialize method.