phpBB API Documentation
Interface

phpbb\db\tools\tools_interface

interface tools_interface

Interface for a Database Tools for handling cross-db actions such as altering columns, etc.

Methods

null perform_schema_changes(array $schema_changes)

Handle passed database update array.

array sql_list_tables()

Gets a list of tables in the database.

bool sql_table_exists(string $table_name)

Check if table exists

array|true sql_create_table(string $table_name, array $table_data)

Create SQL Table

array|true sql_table_drop(string $table_name)

Drop Table

array sql_list_columns(string $table_name)

Gets a list of columns of a table.

bool sql_column_exists(string $table_name, string $column_name)

Check whether a specified column exist in a table

array|true sql_column_add(string $table_name, string $column_name, array $column_data, bool $inline = false)

Add new column

array|true sql_column_change(string $table_name, string $column_name, array $column_data, bool $inline = false)

Change column type (not name!)

array|true sql_column_remove(string $table_name, string $column_name, bool $inline = false)

Drop column

array sql_list_index(string $table_name)

List all of the indices that belong to a table

bool sql_index_exists(string $table_name, string $index_name)

Check if a specified index exists in table.

array|true sql_create_index(string $table_name, string $index_name, string|array $column)

Add index

array|true sql_index_drop(string $table_name, string $index_name)

Drop Index

bool sql_unique_index_exists(string $table_name, string $index_name)

Check if a specified index exists in table.

array|true sql_create_unique_index(string $table_name, string $index_name, string|array $column)

Add unique index

array|true sql_create_primary_key(string $table_name, string|array $column, bool $inline = false)

Add primary key

Details

at line 45
public null perform_schema_changes(array $schema_changes)

Handle passed database update array.

Expected structure... Key being one of the following droptables: Drop tables addtables: Add tables changecolumns: Column changes (only type, not name) addcolumns: Add columns to a table dropkeys: Dropping keys dropcolumns: Removing/Dropping columns addprimarykeys: adding primary keys adduniqueindex: adding an unique index addindex: adding an index (can be column:indexsize if you need to provide size)

The values are in this format: {TABLE NAME} => array( {COLUMN NAME} => array({COLUMN TYPE}, {DEFAULT VALUE}, {OPTIONAL VARIABLES}), {KEY/INDEX NAME} => array({COLUMN NAMES}), )

Parameters

array $schema_changes

Return Value

null

at line 52
public array sql_list_tables()

Gets a list of tables in the database.

Return Value

array Array of table names (all lower case)

at line 60
public bool sql_table_exists(string $table_name)

Check if table exists

Parameters

string $table_name The table name to check for

Return Value

bool true if table exists, else false

at line 69
public array|true sql_create_table(string $table_name, array $table_data)

Create SQL Table

Parameters

string $table_name The table name to create
array $table_data Array containing table data.

Return Value

array|true Statements to run, or true if the statements have been executed

at line 77
public array|true sql_table_drop(string $table_name)

Drop Table

Parameters

string $table_name The table name to drop

Return Value

array|true Statements to run, or true if the statements have been executed

at line 85
public array sql_list_columns(string $table_name)

Gets a list of columns of a table.

Parameters

string $table_name Table name

Return Value

array Array of column names (all lower case)

at line 94
public bool sql_column_exists(string $table_name, string $column_name)

Check whether a specified column exist in a table

Parameters

string $table_name Table to check
string $column_name Column to check

Return Value

bool True if column exists, false otherwise

at line 106
public array|true sql_column_add(string $table_name, string $column_name, array $column_data, bool $inline = false)

Add new column

Parameters

string $table_name Table to modify
string $column_name Name of the column to add
array $column_data Column data
bool $inline Whether the query should actually be run, or return a string for adding the column

Return Value

array|true Statements to run, or true if the statements have been executed

at line 118
public array|true sql_column_change(string $table_name, string $column_name, array $column_data, bool $inline = false)

Change column type (not name!)

Parameters

string $table_name Table to modify
string $column_name Name of the column to modify
array $column_data Column data
bool $inline Whether the query should actually be run, or return a string for modifying the column

Return Value

array|true Statements to run, or true if the statements have been executed

at line 129
public array|true sql_column_remove(string $table_name, string $column_name, bool $inline = false)

Drop column

Parameters

string $table_name Table to modify
string $column_name Name of the column to drop
bool $inline Whether the query should actually be run, or return a string for deleting the column

Return Value

array|true Statements to run, or true if the statements have been executed

at line 141
public array sql_list_index(string $table_name)

List all of the indices that belong to a table

NOTE: does not list - UNIQUE indices - PRIMARY keys

Parameters

string $table_name Table to check

Return Value

array Array with index names

at line 150
public bool sql_index_exists(string $table_name, string $index_name)

Check if a specified index exists in table.

Does not return PRIMARY KEY and UNIQUE indexes.

Parameters

string $table_name Table to check the index at
string $index_name The index name to check

Return Value

bool True if index exists, else false

at line 160
public array|true sql_create_index(string $table_name, string $index_name, string|array $column)

Add index

Parameters

string $table_name Table to modify
string $index_name Name of the index to create
string|array $column Either a string with a column name, or an array with columns

Return Value

array|true Statements to run, or true if the statements have been executed

at line 169
public array|true sql_index_drop(string $table_name, string $index_name)

Drop Index

Parameters

string $table_name Table to modify
string $index_name Name of the index to delete

Return Value

array|true Statements to run, or true if the statements have been executed

at line 180
public bool sql_unique_index_exists(string $table_name, string $index_name)

Check if a specified index exists in table.

NOTE: Does not return normal and PRIMARY KEY indexes

Parameters

string $table_name Table to check the index at
string $index_name The index name to check

Return Value

bool True if index exists, else false

at line 190
public array|true sql_create_unique_index(string $table_name, string $index_name, string|array $column)

Add unique index

Parameters

string $table_name Table to modify
string $index_name Name of the unique index to create
string|array $column Either a string with a column name, or an array with columns

Return Value

array|true Statements to run, or true if the statements have been executed

at line 201
public array|true sql_create_primary_key(string $table_name, string|array $column, bool $inline = false)

Add primary key

Parameters

string $table_name Table to modify
string|array $column Either a string with a column name, or an array with columns
bool $inline Whether the query should actually be run, or return a string for creating the key

Return Value

array|true Statements to run, or true if the statements have been executed