Development Wiki

Umil.table column add

From phpBB Development Wiki

umil::table_column_add –– Add a column to a database table using the Umil Library.


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


Parameter Required/Default Usage
table_name Required The name of the database table to add the column to. 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 add
column_data default array() The column data which will be used to add 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'''),


Example #1

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

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

Example #2

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

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

Example #3

Adding multiple columns with one function call

'phpbb_test''test_foo', array('UINT'0)),
USERS_TABLE'test_bar', array('VCHAR''hello')),

Example #4

adding a boolean column (Tinyint in Mysql, char(1) in oracle, bit in mssql) using the automatic syntax :

'table_column_add' => array(
'phpbb_test''test_foo' , array('BOOL'0)),

See Also