|
@@ -84,12 +84,12 @@ function db_packages_init()
|
|
|
* - 'overwrite' will drop any existing table of the same name.
|
|
|
* - 'error' will return false if the table already exists.
|
|
|
*
|
|
|
- * @param string $table_name
|
|
|
- * @param array $columns in the format specified.
|
|
|
- * @param array $indexes default array(), in the format specified.
|
|
|
- * @param array $parameters default array()
|
|
|
- * @param string $if_exists default 'ignore'
|
|
|
- * @param string $error default 'fatal'
|
|
|
+ * @param string $table_name The name of the table to create
|
|
|
+ * @param array $columns An array of column info in the specified format
|
|
|
+ * @param array $indexes An array of index info in the specified format
|
|
|
+ * @param array $parameters Currently not used
|
|
|
+ * @param string $if_exists What to do if the table exists.
|
|
|
+ * @param string $error
|
|
|
*/
|
|
|
function smf_db_create_table($table_name, $columns, $indexes = array(), $parameters = array(), $if_exists = 'ignore', $error = 'fatal')
|
|
|
{
|
|
@@ -198,10 +198,10 @@ function smf_db_create_table($table_name, $columns, $indexes = array(), $paramet
|
|
|
|
|
|
* Drop a table.
|
|
|
*
|
|
|
- * @param string $table_name
|
|
|
- * @param array $parameters default array()
|
|
|
- * @param bool $error
|
|
|
- * @param string $error default 'fatal'
|
|
|
+ * @param string $table_name The name of the table to drop
|
|
|
+ * @param array $parameters Not used at the moment
|
|
|
+ * @param string $error
|
|
|
+ * @return boolean Whether or not the operation was successful
|
|
|
*/
|
|
|
function smf_db_drop_table($table_name, $parameters = array(), $error = 'fatal')
|
|
|
{
|
|
@@ -236,11 +236,12 @@ function smf_db_drop_table($table_name, $parameters = array(), $error = 'fatal')
|
|
|
|
|
|
* This function adds a column.
|
|
|
*
|
|
|
- * @param string $table_name the name of the table
|
|
|
- * @param array $column_info with column information
|
|
|
- * @param array $parameters default array()
|
|
|
- * @param string $if_exists default 'update'
|
|
|
- * @param string $error default 'fatal'
|
|
|
+ * @param string $table_name The name of the table to add the column to
|
|
|
+ * @param array $column_info An array of column info ({@see smf_db_create_table})
|
|
|
+ * @param array $parameters Not used?
|
|
|
+ * @param string $if_exists What to do if the column exists. If 'update', column is updated.
|
|
|
+ * @param string $error
|
|
|
+ * @return boolean Whether or not the operation was successful
|
|
|
*/
|
|
|
function smf_db_add_column($table_name, $column_info, $parameters = array(), $if_exists = 'update', $error = 'fatal')
|
|
|
{
|
|
@@ -274,10 +275,11 @@ function smf_db_add_column($table_name, $column_info, $parameters = array(), $if
|
|
|
* Removes a column.
|
|
|
*
|
|
|
* We can't reliably do this on SQLite - damn!
|
|
|
- * @param string $table_name
|
|
|
- * @param string $column_name
|
|
|
- * @param array $parameters default array()
|
|
|
- * @param string $error default 'fatal'
|
|
|
+ * @param string $table_name The name of the table to drop the column from
|
|
|
+ * @param string $column_name The name of the column to drop
|
|
|
+ * @param array $parameters Not used?
|
|
|
+ * @param string $error
|
|
|
+ * @return boolean Whether or not the operation was successful
|
|
|
*/
|
|
|
function smf_db_remove_column($table_name, $column_name, $parameters = array(), $error = 'fatal')
|
|
|
{
|
|
@@ -294,11 +296,11 @@ function smf_db_remove_column($table_name, $column_name, $parameters = array(),
|
|
|
|
|
|
* Change a column.
|
|
|
*
|
|
|
- * @param string $table_name
|
|
|
- * @param $old_column
|
|
|
- * @param $column_info
|
|
|
- * @param array $parameters default array()
|
|
|
- * @param string $error default 'fatal'
|
|
|
+ * @param string $table_name The name of the table this column is in
|
|
|
+ * @param string $old_column The name of the column we want to change
|
|
|
+ * @param array $column_info An array of info about the "new" column definition (see {@link smf_db_create_table()})
|
|
|
+ * @param array $parameters Not used?
|
|
|
+ * @param string $error
|
|
|
*/
|
|
|
function smf_db_change_column($table_name, $old_column, $column_info, $parameters = array(), $error = 'fatal')
|
|
|
{
|
|
@@ -315,11 +317,12 @@ function smf_db_change_column($table_name, $old_column, $column_info, $parameter
|
|
|
|
|
|
* Add an index.
|
|
|
*
|
|
|
- * @param string $table_name
|
|
|
- * @param array $index_info
|
|
|
- * @param array $parameters default array()
|
|
|
- * @param string $if_exists default 'update'
|
|
|
- * @param string $error default 'fatal'
|
|
|
+ * @param string $table_name The name of the table to add the index to
|
|
|
+ * @param array $index_info An array of index info (see {@link smf_db_create_table()})
|
|
|
+ * @param array $parameters Not used?
|
|
|
+ * @param string $if_exists What to do if the index exists. If 'update', the definition will be updated.
|
|
|
+ * @param string $error
|
|
|
+ * @return boolean Whether or not the operation was successful
|
|
|
*/
|
|
|
function smf_db_add_index($table_name, $index_info, $parameters = array(), $if_exists = 'update', $error = 'fatal')
|
|
|
{
|
|
@@ -381,10 +384,11 @@ function smf_db_add_index($table_name, $index_info, $parameters = array(), $if_e
|
|
|
|
|
|
* Remove an index.
|
|
|
*
|
|
|
- * @param string $table_name
|
|
|
- * @param string $index_name
|
|
|
- * @param array$parameters default array()
|
|
|
- * @param string $error default 'fatal'
|
|
|
+ * @param string $table_name The name of the table to remove the index from
|
|
|
+ * @param string $index_name The name of the index to remove
|
|
|
+ * @param array $parameters Not used?
|
|
|
+ * @param string $error
|
|
|
+ * @return boolean Whether or not the operation was successful
|
|
|
*/
|
|
|
function smf_db_remove_index($table_name, $index_name, $parameters = array(), $error = 'fatal')
|
|
|
{
|
|
@@ -419,9 +423,10 @@ function smf_db_remove_index($table_name, $index_name, $parameters = array(), $e
|
|
|
|
|
|
* Get the schema formatted name for a type.
|
|
|
*
|
|
|
- * @param string $type_name
|
|
|
- * @param $type_size
|
|
|
- * @param $reverse
|
|
|
+ * @param string $type_name The data type (int, varchar, smallint, etc.)
|
|
|
+ * @param int $type_size The size (8, 255, etc.)
|
|
|
+ * @param boolean $reverse If true, returns specific types for a generic type
|
|
|
+ * @return An array containing the appropriate type and size for this DB type
|
|
|
*/
|
|
|
function smf_db_calculate_type($type_name, $type_size = null, $reverse = false)
|
|
|
{
|
|
@@ -461,8 +466,9 @@ function smf_db_calculate_type($type_name, $type_size = null, $reverse = false)
|
|
|
|
|
|
* Get table structure.
|
|
|
*
|
|
|
- * @param string $table_name
|
|
|
- * @param array $parameters default array()
|
|
|
+ * @param string $table_name The name of the table
|
|
|
+ * @param array $parameters Not used?
|
|
|
+ * @return An array of table structure - the name, the column info from {@link smf_db_list_columns()} and the index info from {@link smf_db_list_indexes()}
|
|
|
*/
|
|
|
function smf_db_table_structure($table_name, $parameters = array())
|
|
|
{
|
|
@@ -481,10 +487,10 @@ function smf_db_table_structure($table_name, $parameters = array())
|
|
|
* Return column information for a table.
|
|
|
* Harder than it should be, on sqlite!
|
|
|
*
|
|
|
- * @param string $table_name
|
|
|
- * @param bool $detail
|
|
|
- * @param array $parameters default array()
|
|
|
- * @return mixed
|
|
|
+ * @param string $table_name The name of the table to get column info for
|
|
|
+ * @param bool $detail Whether or not to return detailed info. If true, returns the column info. If false, just returns the column names.
|
|
|
+ * @param array $parameters Not used?
|
|
|
+ * @return array An array of column names or detailed column info, depending on $detail
|
|
|
*/
|
|
|
function smf_db_list_columns($table_name, $detail = false, $parameters = array())
|
|
|
{
|
|
@@ -547,10 +553,10 @@ function smf_db_list_columns($table_name, $detail = false, $parameters = array()
|
|
|
|
|
|
* Get index information.
|
|
|
*
|
|
|
- * @param string $table_name
|
|
|
- * @param bool $detail
|
|
|
- * @param array $parameters
|
|
|
- * @return mixed
|
|
|
+ * @param string $table_name The name of the table to get indexes for
|
|
|
+ * @param bool $detail Whether or not to return detailed info.
|
|
|
+ * @param array $parameters Not used?
|
|
|
+ * @return array An array of index names or a detailed array of index info, depending on $detail
|
|
|
*/
|
|
|
function smf_db_list_indexes($table_name, $detail = false, $parameters = array())
|
|
|
{
|
|
@@ -609,8 +615,9 @@ function smf_db_list_indexes($table_name, $detail = false, $parameters = array()
|
|
|
|
|
|
* Alter table on SQLite.
|
|
|
*
|
|
|
- * @param string $table_name
|
|
|
- * @param array $columns
|
|
|
+ * @param string $table_name The name of the table
|
|
|
+ * @param array $columns An array of arrays of column info and what to do. Can contain 'remove', an array of names of columns to remove, and/or 'add', an array of details of columns to add (see {@link smf_db_list_columns()})
|
|
|
+ * @return boolean Whether or not the operations were successful
|
|
|
*/
|
|
|
function smf_db_alter_table($table_name, $columns)
|
|
|
{
|