--- C:\Downloads\fluxbb-1.5.1\fluxbb-1.5.1\include\dblayer\mysql.php 2012-11-13 14:31:40.000000000 +0200 +++ C:\wamp\www\fluxbb15\include\dblayer\mysql.php 2012-11-13 20:33:14.000000000 +0200 @@ -300,13 +300,13 @@ return $this->query('DROP TABLE '.($no_prefix ? '' : $this->prefix).$table_name) ? true : false; } function rename_table($old_table, $new_table, $no_prefix = false) { - // If there new table exists and the old one doesn't, then we're happy + // If the new table exists and the old one doesn't, then we're happy if ($this->table_exists($new_table, $no_prefix) && !$this->table_exists($old_table, $no_prefix)) return true; return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$old_table.' RENAME TO '.($no_prefix ? '' : $this->prefix).$new_table) ? true : false; } @@ -318,13 +318,13 @@ $field_type = preg_replace(array_keys($this->datatype_transformations), array_values($this->datatype_transformations), $field_type); if (!is_null($default_value) && !is_int($default_value) && !is_float($default_value)) $default_value = '\''.$this->escape($default_value).'\''; - return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$table_name.' ADD '.$field_name.' '.$field_type.($allow_null ? ' ' : ' NOT NULL').(!is_null($default_value) ? ' DEFAULT '.$default_value : ' ').(!is_null($after_field) ? ' AFTER '.$after_field : '')) ? true : false; + return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$table_name.' ADD '.$field_name.' '.$field_type.($allow_null ? '' : ' NOT NULL').(!is_null($default_value) ? ' DEFAULT '.$default_value : '').(!is_null($after_field) ? ' AFTER '.$after_field : '')) ? true : false; } function alter_field($table_name, $field_name, $field_type, $allow_null, $default_value = null, $after_field = null, $no_prefix = false) { if (!$this->field_exists($table_name, $field_name, $no_prefix)) @@ -332,13 +332,13 @@ $field_type = preg_replace(array_keys($this->datatype_transformations), array_values($this->datatype_transformations), $field_type); if (!is_null($default_value) && !is_int($default_value) && !is_float($default_value)) $default_value = '\''.$this->escape($default_value).'\''; - return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$table_name.' MODIFY '.$field_name.' '.$field_type.($allow_null ? ' ' : ' NOT NULL').(!is_null($default_value) ? ' DEFAULT '.$default_value : ' ').(!is_null($after_field) ? ' AFTER '.$after_field : '')) ? true : false; + return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$table_name.' MODIFY '.$field_name.' '.$field_type.($allow_null ? '' : ' NOT NULL').(!is_null($default_value) ? ' DEFAULT '.$default_value : '').(!is_null($after_field) ? ' AFTER '.$after_field : '')) ? true : false; } function drop_field($table_name, $field_name, $no_prefix = false) { if (!$this->field_exists($table_name, $field_name, $no_prefix)) --- C:\Downloads\fluxbb-1.5.1\fluxbb-1.5.1\include\dblayer\mysql_innodb.php 2012-11-13 14:31:40.000000000 +0200 +++ C:\wamp\www\fluxbb15\include\dblayer\mysql_innodb.php 2012-11-13 20:33:37.000000000 +0200 @@ -314,13 +314,13 @@ return $this->query('DROP TABLE '.($no_prefix ? '' : $this->prefix).$table_name) ? true : false; } function rename_table($old_table, $new_table, $no_prefix = false) { - // If there new table exists and the old one doesn't, then we're happy + // If the new table exists and the old one doesn't, then we're happy if ($this->table_exists($new_table, $no_prefix) && !$this->table_exists($old_table, $no_prefix)) return true; return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$old_table.' RENAME TO '.($no_prefix ? '' : $this->prefix).$new_table) ? true : false; } @@ -332,13 +332,13 @@ $field_type = preg_replace(array_keys($this->datatype_transformations), array_values($this->datatype_transformations), $field_type); if (!is_null($default_value) && !is_int($default_value) && !is_float($default_value)) $default_value = '\''.$this->escape($default_value).'\''; - return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$table_name.' ADD '.$field_name.' '.$field_type.($allow_null ? ' ' : ' NOT NULL').(!is_null($default_value) ? ' DEFAULT '.$default_value : ' ').(!is_null($after_field) ? ' AFTER '.$after_field : '')) ? true : false; + return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$table_name.' ADD '.$field_name.' '.$field_type.($allow_null ? '' : ' NOT NULL').(!is_null($default_value) ? ' DEFAULT '.$default_value : '').(!is_null($after_field) ? ' AFTER '.$after_field : '')) ? true : false; } function alter_field($table_name, $field_name, $field_type, $allow_null, $default_value = null, $after_field = null, $no_prefix = false) { if (!$this->field_exists($table_name, $field_name, $no_prefix)) @@ -346,13 +346,13 @@ $field_type = preg_replace(array_keys($this->datatype_transformations), array_values($this->datatype_transformations), $field_type); if (!is_null($default_value) && !is_int($default_value) && !is_float($default_value)) $default_value = '\''.$this->escape($default_value).'\''; - return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$table_name.' MODIFY '.$field_name.' '.$field_type.($allow_null ? ' ' : ' NOT NULL').(!is_null($default_value) ? ' DEFAULT '.$default_value : ' ').(!is_null($after_field) ? ' AFTER '.$after_field : '')) ? true : false; + return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$table_name.' MODIFY '.$field_name.' '.$field_type.($allow_null ? '' : ' NOT NULL').(!is_null($default_value) ? ' DEFAULT '.$default_value : '').(!is_null($after_field) ? ' AFTER '.$after_field : '')) ? true : false; } function drop_field($table_name, $field_name, $no_prefix = false) { if (!$this->field_exists($table_name, $field_name, $no_prefix)) --- C:\Downloads\fluxbb-1.5.1\fluxbb-1.5.1\include\dblayer\mysqli.php 2012-11-13 14:31:40.000000000 +0200 +++ C:\wamp\www\fluxbb15\include\dblayer\mysqli.php 2012-11-13 20:27:27.000000000 +0200 @@ -325,13 +325,13 @@ $field_type = preg_replace(array_keys($this->datatype_transformations), array_values($this->datatype_transformations), $field_type); if (!is_null($default_value) && !is_int($default_value) && !is_float($default_value)) $default_value = '\''.$this->escape($default_value).'\''; - return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$table_name.' ADD '.$field_name.' '.$field_type.($allow_null ? ' ' : ' NOT NULL').(!is_null($default_value) ? ' DEFAULT '.$default_value : ' ').(!is_null($after_field) ? ' AFTER '.$after_field : '')) ? true : false; + return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$table_name.' ADD '.$field_name.' '.$field_type.($allow_null ? '' : ' NOT NULL').(!is_null($default_value) ? ' DEFAULT '.$default_value : '').(!is_null($after_field) ? ' AFTER '.$after_field : '')) ? true : false; } function alter_field($table_name, $field_name, $field_type, $allow_null, $default_value = null, $after_field = null, $no_prefix = false) { if (!$this->field_exists($table_name, $field_name, $no_prefix)) @@ -339,13 +339,13 @@ $field_type = preg_replace(array_keys($this->datatype_transformations), array_values($this->datatype_transformations), $field_type); if (!is_null($default_value) && !is_int($default_value) && !is_float($default_value)) $default_value = '\''.$this->escape($default_value).'\''; - return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$table_name.' MODIFY '.$field_name.' '.$field_type.($allow_null ? ' ' : ' NOT NULL').(!is_null($default_value) ? ' DEFAULT '.$default_value : ' ').(!is_null($after_field) ? ' AFTER '.$after_field : '')) ? true : false; + return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$table_name.' MODIFY '.$field_name.' '.$field_type.($allow_null ? '' : ' NOT NULL').(!is_null($default_value) ? ' DEFAULT '.$default_value : '').(!is_null($after_field) ? ' AFTER '.$after_field : '')) ? true : false; } function drop_field($table_name, $field_name, $no_prefix = false) { if (!$this->field_exists($table_name, $field_name, $no_prefix)) --- C:\Downloads\fluxbb-1.5.1\fluxbb-1.5.1\include\dblayer\mysqli_innodb.php 2012-11-13 14:31:40.000000000 +0200 +++ C:\wamp\www\fluxbb15\include\dblayer\mysqli_innodb.php 2012-11-13 20:33:28.000000000 +0200 @@ -320,13 +320,13 @@ return $this->query('DROP TABLE '.($no_prefix ? '' : $this->prefix).$table_name) ? true : false; } function rename_table($old_table, $new_table, $no_prefix = false) { - // If there new table exists and the old one doesn't, then we're happy + // If the new table exists and the old one doesn't, then we're happy if ($this->table_exists($new_table, $no_prefix) && !$this->table_exists($old_table, $no_prefix)) return true; return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$old_table.' RENAME TO '.($no_prefix ? '' : $this->prefix).$new_table) ? true : false; } @@ -338,13 +338,13 @@ $field_type = preg_replace(array_keys($this->datatype_transformations), array_values($this->datatype_transformations), $field_type); if (!is_null($default_value) && !is_int($default_value) && !is_float($default_value)) $default_value = '\''.$this->escape($default_value).'\''; - return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$table_name.' ADD '.$field_name.' '.$field_type.($allow_null ? ' ' : ' NOT NULL').(!is_null($default_value) ? ' DEFAULT '.$default_value : ' ').(!is_null($after_field) ? ' AFTER '.$after_field : '')) ? true : false; + return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$table_name.' ADD '.$field_name.' '.$field_type.($allow_null ? '' : ' NOT NULL').(!is_null($default_value) ? ' DEFAULT '.$default_value : '').(!is_null($after_field) ? ' AFTER '.$after_field : '')) ? true : false; } function alter_field($table_name, $field_name, $field_type, $allow_null, $default_value = null, $after_field = null, $no_prefix = false) { if (!$this->field_exists($table_name, $field_name, $no_prefix)) @@ -352,13 +352,13 @@ $field_type = preg_replace(array_keys($this->datatype_transformations), array_values($this->datatype_transformations), $field_type); if (!is_null($default_value) && !is_int($default_value) && !is_float($default_value)) $default_value = '\''.$this->escape($default_value).'\''; - return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$table_name.' MODIFY '.$field_name.' '.$field_type.($allow_null ? ' ' : ' NOT NULL').(!is_null($default_value) ? ' DEFAULT '.$default_value : ' ').(!is_null($after_field) ? ' AFTER '.$after_field : '')) ? true : false; + return $this->query('ALTER TABLE '.($no_prefix ? '' : $this->prefix).$table_name.' MODIFY '.$field_name.' '.$field_type.($allow_null ? '' : ' NOT NULL').(!is_null($default_value) ? ' DEFAULT '.$default_value : '').(!is_null($after_field) ? ' AFTER '.$after_field : '')) ? true : false; } function drop_field($table_name, $field_name, $no_prefix = false) { if (!$this->field_exists($table_name, $field_name, $no_prefix)) --- C:\Downloads\fluxbb-1.5.1\fluxbb-1.5.1\include\dblayer\sqlite.php 2012-11-13 14:31:40.000000000 +0200 +++ C:\wamp\www\fluxbb15\include\dblayer\sqlite.php 2012-11-13 20:16:55.000000000 +0200 @@ -346,33 +346,33 @@ return true; return $this->query('DROP TABLE '.($no_prefix ? '' : $this->prefix).$this->escape($table_name)) ? true : false; } - function rename_table($old_name, $new_name, $no_prefix = false) + function rename_table($old_table, $new_table, $no_prefix = false) { // If the new table exists and the old one doesn't, then we're happy if ($this->table_exists($new_table, $no_prefix) && !$this->table_exists($old_table, $no_prefix)) return true; - $table = $this->get_table_info($old_name, $no_prefix); + $table = $this->get_table_info($old_table, $no_prefix); // Create new table - $newtable = str_replace('CREATE TABLE '.($no_prefix ? '' : $this->prefix).$this->escape($old_name).' (', 'CREATE TABLE '.($no_prefix ? '' : $this->prefix).$this->escape($new_name).' (', $table['sql']); + $newtable = str_replace('CREATE TABLE '.($no_prefix ? '' : $this->prefix).$this->escape($old_table).' (', 'CREATE TABLE '.($no_prefix ? '' : $this->prefix).$this->escape($new_name).' (', $table['sql']); $result = $this->query($newtable) ? true : false; // Recreate indexes if (!empty($table['indices'])) { foreach ($table['indices'] as $cur_index) $result &= $this->query($cur_index) ? true : false; } // Copy content across - $result &= $this->query('INSERT INTO '.($no_prefix ? '' : $this->prefix).$this->escape($new_name).' SELECT * FROM '.($no_prefix ? '' : $this->prefix).$this->escape($old_name)) ? true : false; + $result &= $this->query('INSERT INTO '.($no_prefix ? '' : $this->prefix).$this->escape($new_name).' SELECT * FROM '.($no_prefix ? '' : $this->prefix).$this->escape($old_table)) ? true : false; // Drop old table $result &= $this->drop_table($table_name, $no_prefix); return $result; } @@ -433,18 +433,21 @@ $result = $this->query($tmptable) ? true : false; $result &= $this->query('INSERT INTO '.($no_prefix ? '' : $this->prefix).$this->escape($table_name).'_t'.$now.' SELECT * FROM '.($no_prefix ? '' : $this->prefix).$this->escape($table_name)) ? true : false; // Create new table sql $field_type = preg_replace(array_keys($this->datatype_transformations), array_values($this->datatype_transformations), $field_type); $query = $field_type; + if (!$allow_null) $query .= ' NOT NULL'; - if (is_null($default_value) || $default_value === '') + + if ($default_value === '') $default_value = '\'\''; - $query .= ' DEFAULT '.$default_value; + if (!is_null($default_value)) + $query .= ' DEFAULT '.$default_value; $old_columns = array_keys($table['columns']); // Determine the proper offset if (!is_null($after_field)) $offset = array_search($after_field, array_keys($table['columns']), true) + 1; @@ -493,13 +496,13 @@ $result &= $this->drop_table($table_name.'_t'.$now, $no_prefix); return $result; } - function alter_field($table_name, $field_name, $field_type, $allow_null, $default_value = null, $after_field = 0, $no_prefix = false) + function alter_field($table_name, $field_name, $field_type, $allow_null, $default_value = null, $after_field = null, $no_prefix = false) { // Unneeded for SQLite return true; }