File/program/install/tabledata.php

Description

/program/install/tabledata.php defines core data in a generic way

This file contains the essential data for a new installation, i.e. the items in the configuration table that should exist, etc. This is all done in a generic (database-independent) way. This file defines an array called '$tabledata' which contains one or more arrays with a tablename and yet another array with fieldname/fieldvalue pairs. This construction with nested arrays is converted to an actual SQL-statement in a function. That function also takes care of the table prefix, so we can simple refer to the bare tablenames here.

The reason to use this nested array construction is that it is easier to see which field gets which value compared to a (possibly very long) SQL-statement. Furthermore you don't need to worry about prefixing the table name and it is almost impossible to mismatch the number of fields and the number of values because they are combined in a $key => $value pair. Finally, all strings are automagically escaped with $DB->escape() in the function that constructs the actual SQL-statement.

This definition file uses the PHP variable types, i.e. if you want to insert a number, you can specify a number (without quotes) and for a boolean you can use the PHP-values TRUE or FALSE. Here's an example.

$tabledata = array();
$tabledata[] = array('table' => 'tablename_without_prefix',
                     'fields' => array(
                         'string_field' => 'This is a string, even with unescaped "quotes"',
                         'boolean_field' => TRUE,
                         'integer_field' => 123,
                         'date_field' => '2008-02-01 23:34:45',
                         'double_field' => 1.234567,
                         'field_with_null_value' => NULL
                        )
                    );
Note that a date field is handled like a string field.

Documentation generated on Tue, 28 Jun 2016 19:12:09 +0200 by phpDocumentor 1.4.0