PHP Class CI_DB_forge, TastyIgniter

Author: EllisLab Dev Team
ファイルを表示 Open project: tastyigniter/tastyigniter Class Usage Examples

Public Properties

Property Type Description
$db_char_set string Database character set
$fields array Fields data
$keys array Keys data
$primary_keys array Primary Keys data

Protected Properties

Property Type Description
$_create_database string CREATE DATABASE statement
$_create_table string CREATE TABLE statement
$_create_table_if string CREATE TABLE IF statement
$_create_table_keys boolean Whether table keys are created from within the CREATE TABLE statement.
$_default string DEFAULT value representation in CREATE/ALTER TABLE statements
$_drop_database string DROP DATABASE statement
$_drop_table_if string DROP TABLE IF EXISTS statement
$_null string NULL value representation in CREATE/ALTER TABLE statements
$_rename_table string RENAME TABLE statement
$_unsigned boolean | array UNSIGNED support
$db object Database object

Public Methods

Method Description
__construct ( &$db ) : void Class constructor
add_column ( string $table, array $field, string $_after = NULL ) : boolean Column Add
add_field ( array $field ) : CI_DB_forge Add Field
add_key ( string $key, boolean $primary = FALSE ) : CI_DB_forge Add Key
create_database ( string $db_name ) : boolean Create database
create_table ( string $table, boolean $if_not_exists = FALSE, array $attributes = [] ) : boolean Create Table
drop_column ( string $table, string $column_name ) : boolean Column Drop
drop_database ( string $db_name ) : boolean Drop database
drop_table ( string $table_name, boolean $if_exists = FALSE ) : boolean Drop Table
modify_column ( string $table, string $field ) : boolean Column Modify
rename_table ( string $table_name, string $new_table_name ) : boolean Rename Table

Protected Methods

Method Description
_alter_table ( string $alter_type, string $table, mixed $field ) : string | string[] ALTER TABLE
_attr_auto_increment ( &$attributes, &$field ) : void Field attribute AUTO_INCREMENT
_attr_default ( &$attributes, &$field ) : void Field attribute DEFAULT
_attr_type ( &$attributes ) : void Field attribute TYPE
_attr_unique ( &$attributes, &$field ) : void Field attribute UNIQUE
_attr_unsigned ( &$attributes, &$field ) : void Field attribute UNSIGNED
_create_table ( string $table, boolean $if_not_exists, array $attributes ) : mixed Create Table
_create_table_attr ( array $attributes ) : string CREATE TABLE attributes
_drop_table ( string $table, boolean $if_exists ) : string Drop Table
_process_column ( array $field ) : string Process column
_process_fields ( boolean $create_table = FALSE ) : array Process fields
_process_indexes ( string $table ) : string Process indexes
_process_primary_keys ( string $table ) : string Process primary keys
_reset ( ) : void Reset

Method Details

__construct() public method

Class constructor
public __construct ( &$db ) : void
return void

_alter_table() protected method

ALTER TABLE
protected _alter_table ( string $alter_type, string $table, mixed $field ) : string | string[]
$alter_type string ALTER type
$table string Table name
$field mixed Column definition
return string | string[]

_attr_auto_increment() protected method

Field attribute AUTO_INCREMENT
protected _attr_auto_increment ( &$attributes, &$field ) : void
return void

_attr_default() protected method

Field attribute DEFAULT
protected _attr_default ( &$attributes, &$field ) : void
return void

_attr_type() protected method

Performs a data type mapping between different databases.
protected _attr_type ( &$attributes ) : void
return void

_attr_unique() protected method

Field attribute UNIQUE
protected _attr_unique ( &$attributes, &$field ) : void
return void

_attr_unsigned() protected method

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
protected _attr_unsigned ( &$attributes, &$field ) : void
return void

_create_table() protected method

Create Table
protected _create_table ( string $table, boolean $if_not_exists, array $attributes ) : mixed
$table string Table name
$if_not_exists boolean Whether to add 'IF NOT EXISTS' condition
$attributes array Associative array of table attributes
return mixed

_create_table_attr() protected method

CREATE TABLE attributes
protected _create_table_attr ( array $attributes ) : string
$attributes array Associative array of table attributes
return string

_drop_table() protected method

Generates a platform-specific DROP TABLE string
protected _drop_table ( string $table, boolean $if_exists ) : string
$table string Table name
$if_exists boolean Whether to add an IF EXISTS condition
return string

_process_column() protected method

Process column
protected _process_column ( array $field ) : string
$field array
return string

_process_fields() protected method

Process fields
protected _process_fields ( boolean $create_table = FALSE ) : array
$create_table boolean
return array

_process_indexes() protected method

Process indexes
protected _process_indexes ( string $table ) : string
$table string
return string

_process_primary_keys() protected method

Process primary keys
protected _process_primary_keys ( string $table ) : string
$table string Table name
return string

_reset() protected method

Resets table creation vars
protected _reset ( ) : void
return void

add_column() public method

Column Add
public add_column ( string $table, array $field, string $_after = NULL ) : boolean
$table string Table name
$field array Column definition
$_after string Column for AFTER clause (deprecated)
return boolean

add_field() public method

Add Field
public add_field ( array $field ) : CI_DB_forge
$field array
return CI_DB_forge

add_key() public method

Add Key
public add_key ( string $key, boolean $primary = FALSE ) : CI_DB_forge
$key string
$primary boolean
return CI_DB_forge

create_database() public method

Create database
public create_database ( string $db_name ) : boolean
$db_name string
return boolean

create_table() public method

Create Table
public create_table ( string $table, boolean $if_not_exists = FALSE, array $attributes = [] ) : boolean
$table string Table name
$if_not_exists boolean Whether to add IF NOT EXISTS condition
$attributes array Associative array of table attributes
return boolean

drop_column() public method

Column Drop
public drop_column ( string $table, string $column_name ) : boolean
$table string Table name
$column_name string Column name
return boolean

drop_database() public method

Drop database
public drop_database ( string $db_name ) : boolean
$db_name string
return boolean

drop_table() public method

Drop Table
public drop_table ( string $table_name, boolean $if_exists = FALSE ) : boolean
$table_name string Table name
$if_exists boolean Whether to add an IF EXISTS condition
return boolean

modify_column() public method

Column Modify
public modify_column ( string $table, string $field ) : boolean
$table string Table name
$field string Column definition
return boolean

rename_table() public method

Rename Table
public rename_table ( string $table_name, string $new_table_name ) : boolean
$table_name string Old table name
$new_table_name string New table name
return boolean

Property Details

$_create_database protected_oe property

CREATE DATABASE statement
protected string $_create_database
return string

$_create_table protected_oe property

CREATE TABLE statement
protected string $_create_table
return string

$_create_table_if protected_oe property

CREATE TABLE IF statement
protected string $_create_table_if
return string

$_create_table_keys protected_oe property

Whether table keys are created from within the CREATE TABLE statement.
protected bool $_create_table_keys
return boolean

$_default protected_oe property

DEFAULT value representation in CREATE/ALTER TABLE statements
protected string $_default
return string

$_drop_database protected_oe property

DROP DATABASE statement
protected string $_drop_database
return string

$_drop_table_if protected_oe property

DROP TABLE IF EXISTS statement
protected string $_drop_table_if
return string

$_null protected_oe property

NULL value representation in CREATE/ALTER TABLE statements
protected string $_null
return string

$_rename_table protected_oe property

RENAME TABLE statement
protected string $_rename_table
return string

$_unsigned protected_oe property

UNSIGNED support
protected bool|array $_unsigned
return boolean | array

$db protected_oe property

Database object
protected object $db
return object

$db_char_set public_oe property

Database character set
public string $db_char_set
return string

$fields public_oe property

Fields data
public array $fields
return array

$keys public_oe property

Keys data
public array $keys
return array

$primary_keys public_oe property

Primary Keys data
public array $primary_keys
return array