Constants

MYSQL

MYSQL

Constants for database types

PGSQL

PGSQL

SQLITE

SQLITE

SQLSRV

SQLSRV

BACKTICK

BACKTICK

Constants for id quote types

BRACKET

BRACKET

DOUBLE_QUOTE

DOUBLE_QUOTE

NO_QUOTE

NO_QUOTE

Properties

$table

$table : string

Table name

Type

string

$info

$info : array

Table info

Type

array

$dbType

$dbType : integer

Database type

Type

integer

$idQuoteType

$idQuoteType : string

ID quote type

Type

string

$placeholder

$placeholder : string

SQL placeholder

Type

string

$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

Methods

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

getIdQuoteType()

getIdQuoteType() : integer

Get the quote ID type

Returns

integer

getPlaceholder()

getPlaceholder() : string

Get the SQL placeholder

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

addColumn()

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

Add a column

Parameters

string $name
string $type
mixed $size
mixed $precision

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

Throws

\Pop\Db\Sql\Schema\Exception

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) : \Pop\Db\Sql\Schema\AbstractStructure

Add an INTEGER column

Parameters

string $name
mixed $size

Returns

\Pop\Db\Sql\Schema\AbstractStructure

int()

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

Add an INT column

Parameters

string $name
mixed $size

Returns

\Pop\Db\Sql\Schema\AbstractStructure

bigInt()

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

Add a BIGINT column

Parameters

string $name
mixed $size

Returns

\Pop\Db\Sql\Schema\AbstractStructure

mediumInt()

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

Add a MEDIUMINT column

Parameters

string $name
mixed $size

Returns

\Pop\Db\Sql\Schema\AbstractStructure

smallInt()

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

Add a SMALLINT column

Parameters

string $name
mixed $size

Returns

\Pop\Db\Sql\Schema\AbstractStructure

tinyInt()

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

Add a TINYINT column

Parameters

string $name
mixed $size

Returns

\Pop\Db\Sql\Schema\AbstractStructure

float()

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

Add a FLOAT column

Parameters

string $name
mixed $size
mixed $precision

Returns

\Pop\Db\Sql\Schema\AbstractStructure

double()

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

Add a DOUBLE column

Parameters

string $name
mixed $size
mixed $precision

Returns

\Pop\Db\Sql\Schema\AbstractStructure

decimal()

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

Add a DECIMAL column

Parameters

string $name
mixed $size
mixed $precision

Returns

\Pop\Db\Sql\Schema\AbstractStructure

numeric()

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

Add a NUMERIC column

Parameters

string $name
mixed $size
mixed $precision

Returns

\Pop\Db\Sql\Schema\AbstractStructure

year()

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

Add a YEAR column

Parameters

string $name
mixed $size

Returns

\Pop\Db\Sql\Schema\AbstractStructure

char()

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

Add a CHAR column

Parameters

string $name
integer $size

Returns

\Pop\Db\Sql\Schema\AbstractStructure

varchar()

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

Add a VARCHAR column

Parameters

string $name
integer $size

Returns

\Pop\Db\Sql\Schema\AbstractStructure

getColumnType()

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

Format column data type and parameters

Parameters

string $name
array $column

Returns

string

getValidColumnType()

getValidColumnType(string  $type) : string

Get valid column type

Parameters

string $type

Returns

string