Documentation

Forge extends Forge
in package

Forge for MySQLi

Table of Contents

$_quoted_table_options  : array<string|int, mixed>
Table Options list which required to be quoted
$_unsigned  : array<string|int, mixed>
UNSIGNED support
$charset  : string
Character set used.
$checkDatabaseExistStr  : string
CHECK DATABASE EXIST statement
$createDatabaseIfStr  : string
CREATE DATABASE IF statement
$createDatabaseStr  : string
CREATE DATABASE statement
$createTableIfStr  : string|bool
CREATE TABLE IF statement
$createTableKeys  : bool
CREATE TABLE keys flag
$createTableStr  : string
CREATE TABLE statement
$db  : BaseConnection
The active database connection.
$default  : string|false
DEFAULT value representation in CREATE/ALTER TABLE statements
$dropConstraintStr  : string
DROP CONSTRAINT statement
$dropDatabaseStr  : string|false
DROP DATABASE statement
$dropTableIfStr  : string|bool
DROP TABLE IF EXISTS statement
$fields  : array<string|int, mixed>
List of fields.
$foreignKeys  : array<string|int, mixed>
List of foreign keys.
$keys  : array<string|int, mixed>
List of keys.
$primaryKeys  : array<string|int, mixed>
List of primary keys.
$renameTableStr  : string|false
RENAME TABLE statement
$uniqueKeys  : array<string|int, mixed>
List of unique keys.
$unsigned  : bool|array<string|int, mixed>
UNSIGNED support
__construct()  : mixed
Constructor.
addColumn()  : bool
Column Add
addField()  : Forge
Add Field
addForeignKey()  : Forge
Add Foreign Key
addKey()  : Forge
Add Key
addPrimaryKey()  : Forge
Add Primary Key
addUniqueKey()  : Forge
Add Unique Key
createDatabase()  : bool
Create database
createTable()  : mixed
Create Table
dropColumn()  : mixed
Column Drop
dropDatabase()  : bool
Drop database
dropForeignKey()  : bool|BaseResult|Query|false|mixed
Foreign Key Drop
dropTable()  : mixed
Drop Table
getConnection()  : ConnectionInterface
Provides access to the forge's current database connection.
modifyColumn()  : bool
Column Modify
renameTable()  : mixed
Rename Table
reset()  : void
Reset
_alterTable()  : string|array<string|int, string>
ALTER TABLE
_attributeAutoIncrement()  : void
Field attribute AUTO_INCREMENT
_attributeDefault()  : null|void
Field attribute DEFAULT
_attributeType()  : void
Field attribute TYPE
_attributeUnique()  : void
Field attribute UNIQUE
_attributeUnsigned()  : null|void
Field attribute UNSIGNED
_createTable()  : mixed
Create Table
_createTableAttributes()  : string
CREATE TABLE attributes
_dropTable()  : string|bool
Drop Table
_processColumn()  : string
Process column
_processFields()  : array<string|int, mixed>
Process fields
_processForeignKeys()  : string
Process foreign keys
_processIndexes()  : string
Process indexes
_processPrimaryKeys()  : string
Process primary keys
databaseExists()  : bool
Determine if a database exists

Properties

$_quoted_table_options

Table Options list which required to be quoted

protected array<string|int, mixed> $_quoted_table_options = ['COMMENT', 'COMPRESSION', 'CONNECTION', 'DATA DIRECTORY', 'INDEX DIRECTORY', 'ENCRYPTION', 'PASSWORD']

$_unsigned

UNSIGNED support

protected array<string|int, mixed> $_unsigned = ['TINYINT', 'SMALLINT', 'MEDIUMINT', 'INT', 'INTEGER', 'BIGINT', 'REAL', 'DOUBLE', 'DOUBLE PRECISION', 'FLOAT', 'DECIMAL', 'NUMERIC']

$charset

Character set used.

protected string $charset = ''

$checkDatabaseExistStr

CHECK DATABASE EXIST statement

protected string $checkDatabaseExistStr

$createDatabaseIfStr

CREATE DATABASE IF statement

protected string $createDatabaseIfStr = 'CREATE DATABASE IF NOT EXISTS %s CHARACTER SET %s COLLATE %s'

$createDatabaseStr

CREATE DATABASE statement

protected string $createDatabaseStr = 'CREATE DATABASE %s CHARACTER SET %s COLLATE %s'

$createTableIfStr

CREATE TABLE IF statement

protected string|bool $createTableIfStr = 'CREATE TABLE IF NOT EXISTS'

$createTableKeys

CREATE TABLE keys flag

protected bool $createTableKeys = true

Whether table keys are created from within the CREATE TABLE statement.

$createTableStr

CREATE TABLE statement

protected string $createTableStr = "%s %s (%s )"

$default

DEFAULT value representation in CREATE/ALTER TABLE statements

protected string|false $default = ' DEFAULT '

$dropConstraintStr

DROP CONSTRAINT statement

protected string $dropConstraintStr = 'ALTER TABLE %s DROP FOREIGN KEY %s'

$dropDatabaseStr

DROP DATABASE statement

protected string|false $dropDatabaseStr = 'DROP DATABASE %s'

$dropTableIfStr

DROP TABLE IF EXISTS statement

protected string|bool $dropTableIfStr = 'DROP TABLE IF EXISTS'

$fields

List of fields.

protected array<string|int, mixed> $fields = []

$foreignKeys

List of foreign keys.

protected array<string|int, mixed> $foreignKeys = []

$keys

List of keys.

protected array<string|int, mixed> $keys = []

$primaryKeys

List of primary keys.

protected array<string|int, mixed> $primaryKeys = []

$renameTableStr

RENAME TABLE statement

protected string|false $renameTableStr = 'ALTER TABLE %s RENAME TO %s;'

$uniqueKeys

List of unique keys.

protected array<string|int, mixed> $uniqueKeys = []

$unsigned

UNSIGNED support

protected bool|array<string|int, mixed> $unsigned = true

Methods

addColumn()

Column Add

public addColumn(string $table, string|array<string|int, mixed> $field) : bool
Parameters
$table : string

Table name

$field : string|array<string|int, mixed>

Column definition

Tags
throws
DatabaseException
Return values
bool

addField()

Add Field

public addField(array<string|int, mixed>|string $field) : Forge
Parameters
$field : array<string|int, mixed>|string
Return values
Forge

addForeignKey()

Add Foreign Key

public addForeignKey([string $fieldName = '' ][, string $tableName = '' ][, string $tableField = '' ][, string $onUpdate = '' ][, string $onDelete = '' ]) : Forge
Parameters
$fieldName : string = ''
$tableName : string = ''
$tableField : string = ''
$onUpdate : string = ''
$onDelete : string = ''
Tags
throws
DatabaseException
Return values
Forge

addKey()

Add Key

public addKey(string|array<string|int, mixed> $key[, bool $primary = false ][, bool $unique = false ]) : Forge
Parameters
$key : string|array<string|int, mixed>
$primary : bool = false
$unique : bool = false
Return values
Forge

addPrimaryKey()

Add Primary Key

public addPrimaryKey(string|array<string|int, mixed> $key) : Forge
Parameters
$key : string|array<string|int, mixed>
Return values
Forge

addUniqueKey()

Add Unique Key

public addUniqueKey(string|array<string|int, mixed> $key) : Forge
Parameters
$key : string|array<string|int, mixed>
Return values
Forge

createDatabase()

Create database

public createDatabase(string $dbName[, bool $ifNotExists = false ]) : bool
Parameters
$dbName : string
$ifNotExists : bool = false

Whether to add IF NOT EXISTS condition

Tags
throws
DatabaseException
Return values
bool

createTable()

Create Table

public createTable(string $table[, bool $ifNotExists = false ][, array<string|int, mixed> $attributes = [] ]) : mixed
Parameters
$table : string

Table name

$ifNotExists : bool = false

Whether to add IF NOT EXISTS condition

$attributes : array<string|int, mixed> = []

Associative array of table attributes

Tags
throws
DatabaseException
Return values
mixed

dropColumn()

Column Drop

public dropColumn(string $table, string|array<string|int, mixed> $columnName) : mixed
Parameters
$table : string

Table name

$columnName : string|array<string|int, mixed>

Column name Array or comma separated

Tags
throws
DatabaseException
Return values
mixed

dropDatabase()

Drop database

public dropDatabase(string $dbName) : bool
Parameters
$dbName : string
Tags
throws
DatabaseException
Return values
bool

dropForeignKey()

Foreign Key Drop

public dropForeignKey(string $table, string $foreignName) : bool|BaseResult|Query|false|mixed
Parameters
$table : string

Table name

$foreignName : string

Foreign name

Tags
throws
DatabaseException
Return values
bool|BaseResult|Query|false|mixed

dropTable()

Drop Table

public dropTable(string $tableName[, bool $ifExists = false ][, bool $cascade = false ]) : mixed
Parameters
$tableName : string

Table name

$ifExists : bool = false

Whether to add an IF EXISTS condition

$cascade : bool = false

Whether to add an CASCADE condition

Tags
throws
DatabaseException
Return values
mixed

modifyColumn()

Column Modify

public modifyColumn(string $table, string|array<string|int, mixed> $field) : bool
Parameters
$table : string

Table name

$field : string|array<string|int, mixed>

Column definition

Tags
throws
DatabaseException
Return values
bool

renameTable()

Rename Table

public renameTable(string $tableName, string $newTableName) : mixed
Parameters
$tableName : string

Old table name

$newTableName : string

New table name

Tags
throws
DatabaseException
Return values
mixed

reset()

Reset

public reset() : void

Resets table creation vars

Return values
void

_alterTable()

ALTER TABLE

protected _alterTable(string $alterType, string $table, mixed $field) : string|array<string|int, string>
Parameters
$alterType : string

ALTER type

$table : string

Table name

$field : mixed

Column definition

Return values
string|array<string|int, string>

_attributeAutoIncrement()

Field attribute AUTO_INCREMENT

protected _attributeAutoIncrement(array<string|int, mixed> &$attributes, array<string|int, mixed> &$field) : void
Parameters
$attributes : array<string|int, mixed>
$field : array<string|int, mixed>
Return values
void

_attributeDefault()

Field attribute DEFAULT

protected _attributeDefault(array<string|int, mixed> &$attributes, array<string|int, mixed> &$field) : null|void
Parameters
$attributes : array<string|int, mixed>
$field : array<string|int, mixed>
Return values
null|void

_attributeType()

Field attribute TYPE

protected _attributeType(array<string|int, mixed> &$attributes) : void

Performs a data type mapping between different databases.

Parameters
$attributes : array<string|int, mixed>
Return values
void

_attributeUnique()

Field attribute UNIQUE

protected _attributeUnique(array<string|int, mixed> &$attributes, array<string|int, mixed> &$field) : void
Parameters
$attributes : array<string|int, mixed>
$field : array<string|int, mixed>
Return values
void

_attributeUnsigned()

Field attribute UNSIGNED

protected _attributeUnsigned(array<string|int, mixed> &$attributes, array<string|int, mixed> &$field) : null|void

Depending on the unsigned property value:

  • TRUE will always set $field['unsigned'] to 'UNSIGNED'
  • FALSE will always set $field['unsigned'] to ''
  • array(TYPE) will set $field['unsigned'] to 'UNSIGNED', if $attributes['TYPE'] is found in the array
  • array(TYPE => UTYPE) will change $field['type'], from TYPE to UTYPE in case of a match
Parameters
$attributes : array<string|int, mixed>
$field : array<string|int, mixed>
Return values
null|void

_createTable()

Create Table

protected _createTable(string $table, bool $ifNotExists, array<string|int, mixed> $attributes) : mixed
Parameters
$table : string

Table name

$ifNotExists : bool

Whether to add 'IF NOT EXISTS' condition

$attributes : array<string|int, mixed>

Associative array of table attributes

Return values
mixed

_createTableAttributes()

CREATE TABLE attributes

protected _createTableAttributes(array<string|int, mixed> $attributes) : string
Parameters
$attributes : array<string|int, mixed>

Associative array of table attributes

Return values
string

_dropTable()

Drop Table

protected _dropTable(string $table, bool $ifExists, bool $cascade) : string|bool

Generates a platform-specific DROP TABLE string

Parameters
$table : string

Table name

$ifExists : bool

Whether to add an IF EXISTS condition

$cascade : bool

Whether to add an CASCADE condition

Return values
string|bool

_processColumn()

Process column

protected _processColumn(array<string|int, mixed> $field) : string
Parameters
$field : array<string|int, mixed>
Return values
string

_processFields()

Process fields

protected _processFields([bool $createTable = false ]) : array<string|int, mixed>
Parameters
$createTable : bool = false
Return values
array<string|int, mixed>

_processForeignKeys()

Process foreign keys

protected _processForeignKeys(string $table) : string
Parameters
$table : string

Table name

Return values
string

_processIndexes()

Process indexes

protected _processIndexes(string $table) : string
Parameters
$table : string

(ignored)

Return values
string

_processPrimaryKeys()

Process primary keys

protected _processPrimaryKeys(string $table) : string
Parameters
$table : string

Table name

Return values
string

databaseExists()

Determine if a database exists

private databaseExists(string $dbName) : bool
Parameters
$dbName : string
Tags
throws
DatabaseException
Return values
bool

Search results