Function DatabaseConnector->add_table_field
Definitions
sources/database.php
- Adds a field to an existing table.Note: this function cannot add a new AUTO key, use add_auto_key for that.Note: this function cannot change the keys in the database on its own (use change_primary_key for that), although you should include * if something will be a key.
- Visibility: public
- Is abstract?: No
- Is static?: No
- Is final?: No
Parameters
Name | Type | Passed by reference? | Variadic? | Default | Set | Range | Description |
---|---|---|---|---|---|---|---|
$table_name | ID_TEXT | No | No | required parameter | N/A | N/A | The table name |
$name | ID_TEXT | No | No | required parameter | N/A | N/A | The field name |
$type | ID_TEXT | No | No | required parameter | N/A | N/A | The field type |
$default | ?mixed | No | No | Null | N/A | N/A | The default value; for a translatable field should still be a string value (null: null default / default default) |
Preview
Code (PHP)
/**
* Adds a field to an existing table.Note: this function cannot add a new AUTO key, use add_auto_key for that.Note: this function cannot change the keys in the database on its own (use change_primary_key for that), although you should include * if something will be a key.
*
* @param ID_TEXT $table_name The table name
* @param ID_TEXT $name The field name
* @param ID_TEXT $type The field type
* @param ?mixed $default The default value; for a translatable field should still be a string value (null: null default / default default)
*/
public function add_table_field(string $table_name, string $name, string $type, $default = null)
* Adds a field to an existing table.Note: this function cannot add a new AUTO key, use add_auto_key for that.Note: this function cannot change the keys in the database on its own (use change_primary_key for that), although you should include * if something will be a key.
*
* @param ID_TEXT $table_name The table name
* @param ID_TEXT $name The field name
* @param ID_TEXT $type The field type
* @param ?mixed $default The default value; for a translatable field should still be a string value (null: null default / default default)
*/
public function add_table_field(string $table_name, string $name, string $type, $default = null)