class phpbb_db_tools
Database Tools for handling cross-db actions such as altering columns, etc.
Currently not supported is returning SQL for creating tables.
Properties
| $sql_layer | Current sql layer | |
| object | $db | |
| array | $dbms_type_map | The Column types for every database we support |
| array | $unsigned_types | A list of types being unsigned for better reference in some db's |
| array | $supported_dbms | A list of supported DBMS. |
| $return_statements | This is set to true if user only wants to return the 'to-be-executed' SQL statement(s) (as an array). |
Methods
|
phpbb_db_tools(phpbb_dbal $db, bool $return_statements = false)
Constructor. |
||
| array |
sql_list_tables()
Gets a list of tables in the database. |
|
| bool |
sql_table_exists(string $table_name)
Check if table exists |
|
| array |
sql_create_table(string $table_name, array $table_data)
Create SQL Table |
|
|
perform_schema_changes($schema_changes)
Handle passed database update array. |
||
| array |
sql_list_columns(string $table)
Gets a list of columns of a table. |
|
| bool |
sql_column_exists(string $table, string $column_name)
Check whether a specified column exist in a table |
|
| bool |
sql_index_exists(string $table_name, string $index_name)
Check if a specified index exists in table. |
|
| bool |
sql_unique_index_exists(string $table_name, string $index_name)
Check if a specified index exists in table. |
|
|
_sql_run_sql($statements)
Private method for performing sql statements (either execute them or return them) |
||
|
sql_prepare_column_data($table_name, $column_name, $column_data)
Function to prepare some column information for better usage |
||
|
sql_column_add($table_name, $column_name, $column_data, $inline = false)
Add new column |
||
|
sql_column_remove($table_name, $column_name, $inline = false)
Drop column |
||
|
sql_index_drop($table_name, $index_name)
Drop Index |
||
|
sql_table_drop($table_name)
Drop Table |
||
|
sql_create_primary_key($table_name, $column, $inline = false)
Add primary key |
||
|
sql_create_unique_index($table_name, $index_name, $column)
Add unique index |
||
|
sql_create_index($table_name, $index_name, $column)
Add index |
||
|
sql_list_index($table_name)
List all of the indices that belong to a table, does not count: * UNIQUE indices * PRIMARY keys |
||
|
sql_column_change($table_name, $column_name, $column_data, $inline = false)
Change column type (not name!) |
Details
at line 308
public
phpbb_db_tools(phpbb_dbal $db, bool $return_statements = false)
Constructor.
Set DB Object and set {@link $returnstatements returnstatements}.
at line 355
public array
sql_list_tables()
Gets a list of tables in the database.
at line 417
public bool
sql_table_exists(string $table_name)
Check if table exists
at line 439
public array
sql_create_table(string $table_name, array $table_data)
Create SQL Table
at line 691
public
perform_schema_changes($schema_changes)
Handle passed database update array.
Expected structure... Key being one of the following 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}), )
For more information have a look at /develop/createschemafiles.php (only available through SVN)
at line 1076
public array
sql_list_columns(string $table)
Gets a list of columns of a table.
at line 1176
public bool
sql_column_exists(string $table, string $column_name)
Check whether a specified column exist in a table
at line 1191
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.
at line 1296
public bool
sql_unique_index_exists(string $table_name, string $index_name)
Check if a specified index exists in table.
Does not return PRIMARY KEY indexes.
at line 1417
public
_sql_run_sql($statements)
Private method for performing sql statements (either execute them or return them)
at line 1448
public
sql_prepare_column_data($table_name, $column_name, $column_data)
Function to prepare some column information for better usage
at line 1679
public
sql_column_add($table_name, $column_name, $column_data, $inline = false)
Add new column
at line 1806
public
sql_column_remove($table_name, $column_name, $inline = false)
Drop column
at line 1948
public
sql_index_drop($table_name, $index_name)
Drop Index
at line 1978
public
sql_table_drop($table_name)
Drop Table
at line 2046
public
sql_create_primary_key($table_name, $column, $inline = false)
Add primary key
at line 2135
public
sql_create_unique_index($table_name, $index_name, $column)
Add unique index
at line 2172
public
sql_create_index($table_name, $index_name, $column)
Add index
at line 2228
public
sql_list_index($table_name)
List all of the indices that belong to a table, does not count: * UNIQUE indices * PRIMARY keys
at line 2320
public
sql_column_change($table_name, $column_name, $column_data, $inline = false)
Change column type (not name!)