Methods

Stores the database instance to be used.

__construct(string $name, $connection) 

Parameters

$name

string

database connection instance

$connection

Adds a single foreign key to a table

add_foreign_key(string $table, array $foreign_key) : int

Parameters

$table

string

the table name

$foreign_key

array

a single foreign key

Returns

intnumber of affected rows

alter_fields()

alter_fields($type, $table, $fields) 

Parameters

$type

$table

$fields

Creates a database.

create_database(string $database, string $charset, boolean $if_not_exists) : int

Will throw a Database_Exception if it cannot.

Parameters

$database

string

the database name

$charset

string

the character set

$if_not_exists

boolean

whether to add an IF NOT EXISTS statement.

Exceptions

\Fuel\Core\Fuel\Database_Exception

Returns

intthe number of affected rows

Creates an index on that table.

create_index(string $table, string $index_columns, string $index_name, string $index) : bool

access public
author Thomas Edwards

Parameters

$table

string

$index_columns

string

$index_name

string

$index

string

(should be 'unique', 'fulltext', 'spatial' or 'nonclustered')

Returns

bool

Creates a table.

create_table(string $table, array $fields, array $primary_keys, boolean $if_not_exists, string | boolean $engine, string $charset, array $foreign_keys) : int

Parameters

$table

string

the table name

$fields

array

the fields array

$primary_keys

array

an array of primary keys

$if_not_exists

boolean

whether to add an IF NOT EXISTS statement.

$engine

stringboolean

storage engine overwrite

$charset

string

default charset overwrite

$foreign_keys

array

an array of foreign keys

Exceptions

\Database_Exception

Returns

intnumber of affected rows.

Drops a database.

drop_database(string $database) : int

Will throw a Database_Exception if it cannot.

Parameters

$database

string

the database name

Exceptions

\Fuel\Core\Fuel\Database_Exception

Returns

intthe number of affected rows

Drops a foreign key from a table

drop_foreign_key(string $table, string $fk_name) : int

Parameters

$table

string

the table name

$fk_name

string

the foreign key name

Returns

intnumber of affected rows

Drop an index from a table.

drop_index(string $table, string $index_name) : bool

access public
author Thomas Edwards

Parameters

$table

string

$index_name

string

Returns

bool

Drops a table.

drop_table(string $table) : int

Will throw a Database_Exception if it cannot.

Parameters

$table

string

the table name

Exceptions

\Fuel\Core\Fuel\Database_Exception

Returns

intthe number of affected rows

Checks if given field(s) in a given table exists.

field_exists(string $table, string | array $columns) : bool

Parameters

$table

string

Table name

$columns

stringarray

columns to check

Exceptions

\Database_Exception

Returns

bool

Returns string of foreign keys

process_foreign_keys(array $foreign_keys) : string

Parameters

$foreign_keys

array

Array of foreign key rules

Exceptions

\Database_Exception

Returns

stringthe formatted foreign key string

Renames a table.

rename_table(string $table, string $new_table_name) : int

Will throw a Database_Exception if it cannot.

Parameters

$table

string

the old table name

$new_table_name

string

the new table name

Exceptions

\Database_Exception

Returns

intthe number of affected

Generic check if a given table exists.

table_exists(string $table) : bool

Parameters

$table

string

Table name

Exceptions

\Database_Exception

Returns

bool

table_maintenance()

table_maintenance($operation, $table) 

Parameters

$operation

$table

Truncates a table.

truncate_table(string $table) : int

Parameters

$table

string

the table name

Exceptions

\Fuel\Core\Fuel\Database_Exception

Returns

intthe number of affected rows

Formats the default charset.

process_charset(string $charset, bool $is_default, string $collation) : string

Parameters

$charset

string

the character set

$is_default

bool

whether to use default

$collation

string

the collating sequence to be used

Returns

stringthe formatted charset sql

process_fields()

process_fields($fields, $prefix) 

Parameters

$fields

$prefix

 Properties

 

<p>database connection instance</p>

$_connection : \Fuel\Core\Database_Connection

 

<p>database connection config name</p>

$_name : string