phpBB

Development Wiki

Umil.table column update

From phpBB Development Wiki

Revision as of 11:46, 5 May 2012 by Sajaki (Talk | contribs)

umil::table_column_update –– Change/update a column on a database table using the Umil Library.

This can only change/update the column information, like the column type or default. The column name can not be changed with this.

Description

string umil::table_column_update ( mixed $table_name [, string $column_name [, array $column_data ]] )

Parameters

Parameter Required/Default Usage
table_name Required The name of the database table to update the column for. You may just use phpbb_ for the table prefix if you would like. UMIL correctly sets the table prefix to the board's default if you enter in phpbb_
column_name default '' The name of the column to update
column_data default array() The column data which will be used to update the column

Return Values

Returns result or umil_end data

This article is a stub. You can help in improving Olympus Documentation by expanding it.


Column Data

Information for setting up the column data is here. This should be given as an array with the column name being the array key and the value being an array with the data.

In the value array holding the information, the first item is the Database_Type_Map, the second item is the default value, and the third item is optional and to be used for special fields.

For example, setting up an auto increment column:

'user_id'    => array('UINT'NULL'auto_increment')

Or a description field, say for the forum description:

'forum_desc'    => array('TEXT_UNI'''),

Examples

Example #1

Change the column named 'test_foo' to a UINT (unsigned mediumint in MySQL) with the default of 0 on the phpbb_test table.

$umil->table_column_update('phpbb_test''test_foo', array('UINT'0));

Example #2

Change the column named 'test_bar' to a VCHAR (varchar(255) in MySQL) with the default of 'hello' on the phpbb_users table.

$umil->table_column_update(USERS_TABLE'test_bar', array('VCHAR''hello'));

Example #3

Changing multiple columns with one function call

$umil->table_column_update(array(
    array(
'phpbb_test''test_foo', array('UINT'0)),
    array(
USERS_TABLE'test_bar', array('VCHAR''hello')),
));

Example #4

In UMIL automatix syntax:

'table_column_update' => array(
        array(
'phpbb_test''test_foo' , array('VCHAR''')),
),

See Also