Constants

MYSQL

MYSQL = 'MYSQL'

Constants for database types

PGSQL

PGSQL = 'PGSQL'

SQLITE

SQLITE = 'SQLITE'

SQLSRV

SQLSRV = 'SQLSRV'

BACKTICK

BACKTICK = 'BACKTICK'

Constants for id quote types

BRACKET

BRACKET = 'BRACKET'

DOUBLE_QUOTE

DOUBLE_QUOTE = 'DOUBLE_QUOTE'

NO_QUOTE

NO_QUOTE = 'NO_QUOTE'

Properties

$columns

$columns : array

Columns to be added or modified

Type

array

$indices

$indices : array

Indices to be created

Type

array

$constraints

$constraints : array

Constraints to be added

Type

array

$currentColumn

$currentColumn : string

Current column

Type

string

$currentConstraint

$currentConstraint : string

Current constraint

Type

string

$table

$table : string

Table name

Type

string

$info

$info : array

Table info

Type

array

$dbType

$dbType : integer

Database type

Type

integer

$placeholder

$placeholder : string

SQL placeholder

Type

string

$idQuoteType

$idQuoteType : string

ID quote type

Type

string

$openQuote

$openQuote : string

ID open quote

Type

string

$closeQuote

$closeQuote : string

ID close quote

Type

string

$existingColumns

$existingColumns : array

Existing columns in the table

Type

array

$dropColumns

$dropColumns : array

Columns to be dropped

Type

array

$dropIndices

$dropIndices : array

Indices to be dropped

Type

array

$dropConstraints

$dropConstraints : array

Constraints to be dropped

Type

array

Methods

getColumn()

getColumn() : string

Get the current column

Returns

string

constraint()

constraint(string  $constraint) : \Pop\Db\Sql\Schema\AbstractStructure

Set the current constraint

Parameters

string $constraint

Returns

\Pop\Db\Sql\Schema\AbstractStructure

getConstraint()

getConstraint() : string

Get the current constraint

Returns

string

addColumn()

addColumn(string  $name, string  $type, mixed  $size = null, mixed  $precision = null, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a column

Parameters

string $name
string $type
mixed $size
mixed $precision
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

hasColumn()

hasColumn(string  $name) : boolean

Determine if the table has a column

Parameters

string $name

Returns

boolean

addColumnAttribute()

addColumnAttribute(string  $attribute) : \Pop\Db\Sql\Schema\AbstractStructure

Add a custom column attribute

Parameters

string $attribute

Returns

\Pop\Db\Sql\Schema\AbstractStructure

hasIncrement()

hasIncrement() : boolean

Determine if the table has an increment column

Returns

boolean

getIncrement()

getIncrement(boolean  $quote = false) : array

Get the increment column(s)

Parameters

boolean $quote

Returns

array

hasPrimary()

hasPrimary() : boolean

Determine if the table has a primary key column

Returns

boolean

getPrimary()

getPrimary(boolean  $quote = false) : array

Get the primary key column(s)

Parameters

boolean $quote

Returns

array

increment()

increment(integer  $start = 1) : \Pop\Db\Sql\Schema\AbstractStructure

Set the current column as an increment column

Parameters

integer $start

Returns

\Pop\Db\Sql\Schema\AbstractStructure

defaultIs()

defaultIs(mixed  $value) : \Pop\Db\Sql\Schema\AbstractStructure

Set the current column's default value

Parameters

mixed $value

Returns

\Pop\Db\Sql\Schema\AbstractStructure

index()

index(string  $column, string  $name = null, string  $type = 'index') : \Pop\Db\Sql\Schema\AbstractStructure

Create an index

Parameters

string $column
string $name
string $type

Returns

\Pop\Db\Sql\Schema\AbstractStructure

unique()

unique(string  $column = null, string  $name = null) : \Pop\Db\Sql\Schema\AbstractStructure

Create a UNIQUE index

Parameters

string $column
string $name

Returns

\Pop\Db\Sql\Schema\AbstractStructure

primary()

primary(string  $column = null, string  $name = null) : \Pop\Db\Sql\Schema\AbstractStructure

Create a PRIMARY KEY index

Parameters

string $column
string $name

Returns

\Pop\Db\Sql\Schema\AbstractStructure

foreignKey()

foreignKey(string  $column, string  $name = null) : \Pop\Db\Sql\Schema\AbstractStructure

Create a FOREIGN KEY constraint

Parameters

string $column
string $name

Returns

\Pop\Db\Sql\Schema\AbstractStructure

references()

references(string  $foreignTable) : \Pop\Db\Sql\Schema\AbstractStructure

Assign FOREIGN KEY reference table

Parameters

string $foreignTable

Returns

\Pop\Db\Sql\Schema\AbstractStructure

on()

on(string  $foreignColumn) : \Pop\Db\Sql\Schema\AbstractStructure

Assign FOREIGN KEY reference table column

Parameters

string $foreignColumn

Returns

\Pop\Db\Sql\Schema\AbstractStructure

onDelete()

onDelete(string  $action = null) : \Pop\Db\Sql\Schema\AbstractStructure

Assign FOREIGN KEY ON DELETE action

Parameters

string $action

Returns

\Pop\Db\Sql\Schema\AbstractStructure

integer()

integer(string  $name, mixed  $size = null, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add an INTEGER column

Parameters

string $name
mixed $size
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

int()

int(string  $name, mixed  $size = null, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add an INT column

Parameters

string $name
mixed $size
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

bigInt()

bigInt(string  $name, mixed  $size = null, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a BIGINT column

Parameters

string $name
mixed $size
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

mediumInt()

mediumInt(string  $name, mixed  $size = null, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a MEDIUMINT column

Parameters

string $name
mixed $size
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

smallInt()

smallInt(string  $name, mixed  $size = null, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a SMALLINT column

Parameters

string $name
mixed $size
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

tinyInt()

tinyInt(string  $name, mixed  $size = null, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a TINYINT column

Parameters

string $name
mixed $size
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

float()

float(string  $name, mixed  $size = null, mixed  $precision = null, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a FLOAT column

Parameters

string $name
mixed $size
mixed $precision
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

real()

real(string  $name, mixed  $size = null, mixed  $precision = null, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a REAL column

Parameters

string $name
mixed $size
mixed $precision
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

double()

double(string  $name, mixed  $size = null, mixed  $precision = null, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a DOUBLE column

Parameters

string $name
mixed $size
mixed $precision
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

decimal()

decimal(string  $name, mixed  $size = null, mixed  $precision = null, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a DECIMAL column

Parameters

string $name
mixed $size
mixed $precision
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

numeric()

numeric(string  $name, mixed  $size = null, mixed  $precision = null, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a NUMERIC column

Parameters

string $name
mixed $size
mixed $precision
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

date()

date(string  $name, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a DATE column

Parameters

string $name
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

time()

time(string  $name, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a TIME column

Parameters

string $name
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

datetime()

datetime(string  $name, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a DATETIME column

Parameters

string $name
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

timestamp()

timestamp(string  $name, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a TIMESTAMP column

Parameters

string $name
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

year()

year(string  $name, mixed  $size = null, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a YEAR column

Parameters

string $name
mixed $size
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

text()

text(string  $name, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a TEXT column

Parameters

string $name
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

tinyText()

tinyText(string  $name, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a TINYTEXT column

Parameters

string $name
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

mediumText()

mediumText(string  $name, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a MEDIUMTEXT column

Parameters

string $name
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

longText()

longText(string  $name, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a LONGTEXT column

Parameters

string $name
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

blob()

blob(string  $name, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a BLOB column

Parameters

string $name
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

mediumBlob()

mediumBlob(string  $name, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a MEDIUMBLOB column

Parameters

string $name
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

longBlob()

longBlob(string  $name, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a LONGBLOB column

Parameters

string $name
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

char()

char(string  $name, integer  $size = null, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a CHAR column

Parameters

string $name
integer $size
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

varchar()

varchar(string  $name, integer  $size = null, array  $attributes = array()) : \Pop\Db\Sql\Schema\AbstractStructure

Add a VARCHAR column

Parameters

string $name
integer $size
array $attributes

Returns

\Pop\Db\Sql\Schema\AbstractStructure

__construct()

__construct(string  $table, \Pop\Db\Adapter\AbstractAdapter  $db) 

Constructor

Instantiate the ALTER table object

Parameters

string $table
\Pop\Db\Adapter\AbstractAdapter $db

getTable()

getTable() : string

Get the table name

Returns

string

getInfo()

getInfo() : array

Get the table info

Returns

array

renderToStatements()

renderToStatements() : array

Render the table schema to an array of statements

Returns

array

render()

render() : string

Render the table schema

Returns

string

__toString()

__toString() : string

Render the table schema to string

Returns

string

isMysql()

isMysql() : boolean

Determine if the DB type is MySQL

Returns

boolean

isPgsql()

isPgsql() : boolean

Determine if the DB type is PostgreSQL

Returns

boolean

isSqlsrv()

isSqlsrv() : boolean

Determine if the DB type is SQL Server

Returns

boolean

isSqlite()

isSqlite() : boolean

Determine if the DB type is SQLite

Returns

boolean

setIdQuoteType()

setIdQuoteType(string  $type = self::NO_QUOTE) : \Pop\Db\Sql\AbstractSql

Set the quote ID type

Parameters

string $type

Returns

\Pop\Db\Sql\AbstractSql

setPlaceholder()

setPlaceholder(string  $placeholder) : \Pop\Db\Sql\AbstractSql

Set the placeholder

Parameters

string $placeholder

Returns

\Pop\Db\Sql\AbstractSql

getDbType()

getDbType() : integer

Get the current database type

Returns

integer

getPlaceholder()

getPlaceholder() : string

Get the SQL placeholder

Returns

string

getIdQuoteType()

getIdQuoteType() : integer

Get the quote ID type

Returns

integer

getOpenQuote()

getOpenQuote() : string

Get open quote

Returns

string

getCloseQuote()

getCloseQuote() : string

Get close quote

Returns

string

quoteId()

quoteId(string  $identifier) : string

Quote the identifier

Parameters

string $identifier

Returns

string

quote()

quote(string  $value) : string

Quote the value (if it is not a numeric value)

Parameters

string $value

Returns

string

modifyColumn()

modifyColumn(string  $oldName, string  $newName, string  $type = null, mixed  $size = null, mixed  $precision = null) : \Pop\Db\Sql\Schema\Alter

Modify a column

Parameters

string $oldName
string $newName
string $type
mixed $size
mixed $precision

Returns

\Pop\Db\Sql\Schema\Alter

dropColumn()

dropColumn(string  $name) : \Pop\Db\Sql\Schema\Alter

Drop a column

Parameters

string $name

Returns

\Pop\Db\Sql\Schema\Alter

dropIndex()

dropIndex(string  $name) : \Pop\Db\Sql\Schema\Alter

Drop an index

Parameters

string $name

Returns

\Pop\Db\Sql\Schema\Alter

dropConstraint()

dropConstraint(string  $name) : \Pop\Db\Sql\Schema\Alter

Drop a constraint

Parameters

string $name

Returns

\Pop\Db\Sql\Schema\Alter

getColumnSchema()

getColumnSchema(string  $name, array  $column) : string

Format column schema

Parameters

string $name
array $column

Returns

string

init()

init(string  $adapter) : void

Initialize SQL object

Parameters

string $adapter

initQuoteType()

initQuoteType() : void

Initialize quite type