-
FAQ
- Forum Search
- Community
- Online Manual
- Support Helpers of the Month
- Function Database
smf_db_add_index
Description
Adds an index to the specified table
Syntax
bool smf_db_add_index (string $table_name[, array $index_info[, array $parameters[, string $if_exists[, string $error]]]])
Parameter $table_name
Expected type: String
Description: The name of the table to add the index to
Parameter $index_info
Expected type: Array
Description: An array of information about the index
Array Elements of $index_info Key Optional Expected type Description columns no Array An array of column names indicating which columns to add the index on name yes String The desired name of the index (not required for primary keys; if not set, SMF will choose the name) type yes Enumerated String What type of index this should be. Can be 'primary' (for primary key) or 'unique'. If not set, a regular index is created.
Parameter $parameters
Expected type: Array
Description: An array of parameters
Array Elements of $parameters Key Optional Expected type Description no_prefix yes Boolean If true, SMF won't add the db_prefix to the table name
Parameter $if_exists
Expected type: Enumerated String
Description: What to do if the index already exists. If set to an empty string, the function will return false if the index already exists.
Possible string values Allowed values Description 'update' Remove the existing index with the given name and create a new one with the specified parameters
Parameter $error
Expected type: Enumerated String
Description: Error parameter (currently not used?)
Possible string values Allowed values Description 'fatal' Default value
Return value
Expected type: Boolean
Description: True if the index was successfully added/updated, false if the index exists and "if_exists" isn't "update" or no columns are specified
Notes
- If no name is specified, SMF will use the column names separated by an underscore as the name
- Can also be used to add a primary key to a table by setting the 'type' parameter of the index_info array to 'primary'
Advertisement:- Help | Terms and Rules | Go Up ▲
- Copyright © 2022 Simple Machines. All Rights Reserved.
- Page created in 0.014 seconds with 13 queries.
- Forum Search