\Kaoshi

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
table()
__construct()
up()
down()
setAdapter()
getAdapter()
setInput()
getInput()
setOutput()
getOutput()
getName()
setVersion()
getVersion()
execute()
query()
fetchRow()
fetchAll()
insert()
createDatabase()
dropDatabase()
hasTable()
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

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

__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() 

Change Method.

Write your reversible migrations using this method.

More information on writing migrations is available here: http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class

The following commands can be used in this method and Phinx will automatically reverse them when rolling back:

createTable renameTable addColumn renameColumn addIndex addForeignKey

Remember to call "create()" or "update()" and NOT "save()" when working with the Table class.

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

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.