Navigation

Search

smf_db_alter_table

Description

Emulates the "ALTER TABLE" functionality for SQLite 2.x, which doesn't include this

Syntax

bool smf_db_alter_table (string $table_name, array $columns)



Parameter $table_name

Expected type: String
Description: The name of the table to alter



Parameter $columns

Expected type: Array
Description: An array of one or more arrays containing information about columns to add, change or drop. All of these are optional, but at least one must be set.

Array Elements of $columns
Key Optional Expected type Description
add yes Array of arrays An array of arrays containing information about columns to add to the table. Each array can have the following keys: 'name' (column name), 'type' (data type), 'size' (column size or null if no size is required), 'default' (default value (optional)), 'auto' (whether or not this is an auto-incrementing column (optional))
change yes Array of arrays An array of information about columns to change. Each array has the following keys: 'name' (column name), 'type' (data type), 'size' (column size or null if no size is required), 'default' (default value (optional)), 'auto' (whether or not this is an auto-incrementing column (optional))
remove yes Array of arrays An array containing arrays with the names of columns to drop. Each array contains a single key, 'name', whose value is the name of the column to drop



Return value

Expected type: Boolean
Description: Whether or not the operations were successful


Notes

  • Alters the table to add, change or remove columns
  • $columns can contain one to three arrays: 'add' (columns to add), 'change' (columns to change) and 'remove' (columns to drop)
  • Returns true on success, false on failure
View all versions of this function