dbTable::addField PHP Method

addField() public method

$name is the name of the table to which the field should be added. $type is an ADODB datadict field type. The following field types are supported as of ADODB 3.40: - C: varchar - X: CLOB (character large object) or largest varchar size if CLOB is not supported - C2: Multibyte varchar - X2: Multibyte CLOB - B: BLOB (binary large object) - D: Date (some databases do not support this, and we return a datetime type) - T: Datetime or Timestamp - L: Integer field suitable for storing booleans (0 or 1) - I: Integer (mapped to I4) - I1: 1-byte integer - I2: 2-byte integer - I4: 4-byte integer - I8: 8-byte integer - F: Floating point number - N: Numeric or decimal number
public addField ( string $name, string $type, string $size = NULL, array $opts = NULL ) : array
$name string Name of the table to which the field will be added.
$type string ADODB datadict field type.
$size string Field size
$opts array Field options array
return array Field specifier array
    function addField($name, $type, $size = NULL, $opts = NULL)
    {
        $field_id = $this->FieldID($name);
        // Set the field index so we know where we are
        $this->current_field = $field_id;
        // Set the field name (required)
        $this->fields[$field_id]['NAME'] = $name;
        // Set the field type (required)
        $this->fields[$field_id]['TYPE'] = $type;
        // Set the field size (optional)
        if (isset($size)) {
            $this->fields[$field_id]['SIZE'] = $size;
        }
        // Set the field options
        if (isset($opts)) {
            $this->fields[$field_id]['OPTS'][] = $opts;
        }
    }