CI_DB_forge::modify_column PHP Method

modify_column() public method

Column Modify
public modify_column ( string $table, string $field ) : boolean
$table string Table name
$field string Column definition
return boolean
    public function modify_column($table, $field)
    {
        // Work-around for literal column definitions
        is_array($field) or $field = array($field);
        foreach (array_keys($field) as $k) {
            $this->add_field(array($k => $field[$k]));
        }
        if (count($this->fields) === 0) {
            show_error('Field information is required.');
        }
        $sqls = $this->_alter_table('CHANGE', $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;
    }