describe_table
method "describe_table"
Get detailed informations for the table-fields of a given db-table.
The result is also store in an array passed by reference.
@param 1: any valid given tablename incl. TABLE_PREFIX
@param 2: any valid array as a storage - pass by reference!
@param 3: optional one of the following constants
- DESCRIBE_RAW
- [or value 0] will store the filed infos as they are returned form the mysql-server - DESCRIBE_ASSOC
- [or value 1] will store the result with the field "name" as assoc. array. - DESCRIBE_ONLY_NAMES
- [or value 2] will only store the fieldnames in a linear array.
LEPTON_database::describe_table
Returns information about a given table
- $aInfo = [];
- LEPTON_database::getInstance()->describe_table(
- TABLE_PREFIX."mod_example",
- $aInfo,
- LEPTON_database::DESCRIBE_ASSOC
- );
last edit: 08. Mar 2020 CET 12:04:39
A common use of this method is to test a given table for a existing field inside an upgrade-script:
Example given:
- // Add database field "open"
- $fields = array();
-
- $database->describe_table(
- TABLE_PREFIX."mod_accordion",
- $fields,
- LEPTON_database::DESCRIBE_ONLY_NAMES
- );
-
- if (!in_array('open', $fields))
- {
- $database->simple_query(" ALTER TABLE ".TABLE_PREFIX."mod_accordion [...]
- }
last edit: 08. Mar 2020 CET 11:42:04