CI_DB_forge::add_column PHP Method

add_column() public method

Column Add
public add_column ( string $table, array $field, string $_after = NULL ) : boolean
$table string Table name
$field array Column definition
$_after string Column for AFTER clause (deprecated)
return boolean
    public function add_column($table, $field, $_after = NULL)
    {
        // Work-around for literal column definitions
        is_array($field) or $field = array($field);
        foreach (array_keys($field) as $k) {
            // Backwards-compatibility work-around for MySQL/CUBRID AFTER clause (remove in 3.1+)
            if ($_after !== NULL && is_array($field[$k]) && !isset($field[$k]['after'])) {
                $field[$k]['after'] = $_after;
            }
            $this->add_field(array($k => $field[$k]));
        }
        $sqls = $this->_alter_table('ADD', $this->db->dbprefix . $table, $this->_process_fields());
        $this->_reset();
        if ($sqls === FALSE) {
            return $this->db->db_debug ? $this->db->display_error('db_unsupported_feature') : FALSE;
        }
        for ($i = 0, $c = count($sqls); $i < $c; $i++) {
            if ($this->db->query($sqls[$i]) === FALSE) {
                return FALSE;
            }
        }
        return TRUE;
    }