Function dbUpgradeTable
Updates a specific table. Used e. g. by CONTENIDO setup to create or update tables. Function logic: 1 .) Check, if the table exists 2a.) If not, create it with the field specification, exit 2b.) If the table exists, check, if the field exist 3 .) If not, try to find the field using previous names (if specified in $field like 'name1,name2') 4a.) If the field hasn't been found, create the field as specified, exit 4b.) If the field has been found using a previous name (if specified) rename the column to $field 5 .) As the field has been found, check, if the field's type is matching 5a.) If the type is matching, exit 5b.) If the field's content type is not matching, try to convert first (e.g. string to int or int to string), then use the upgrade statement if applicable
Note about the upgrade statement: - the code must be eval'able - the code needs to read $oldVal (old field value) and needs to set $newVal (value to which the field will be set) - $oldVal might be empty if the field didn't exist - $tableValues['fieldname'] contains the already existing values
Copyright: four for business AG <www.4fb.de>
License: http://www.contenido.org/license/LIZENZ.txt
Author: Timo Hummel
Located at includes/functions.database.php
|
$db |
Database instance |
string |
$table |
Name of table to create/update |
string |
$field |
Name of field to create/update |
string |
$type |
Data type of field. Feasible values are all possible data types e. g. int(10), varchar(32), datetime, varchar(255), text, tinyint(1) |
string |
$null |
Parameter to forbid NULL values, feasible values '', 'NULL' or 'YES' where 'NULL' or 'YES' allows NULL values and '' doesn't |
string |
$key |
The field will be added as a primary key, if value is 'PRI', otherwise the value should be empty '' |
string |
$default |
The default value for the field. Feasible is each possible value depending on passed $type |
string |
$extra |
Additional info for the field, e. g. 'auto_increment', if the field should have the AUTO_INCREMENT attribute and empty otherwise. |
string |
$upgradeStatement |
NOT USED AT THE MOMENT |
boolean |
$bRemoveIndexes = false |
Flag to remove all indexes |
boolean
|
|