diff options
author | Robin Sowell <robin.sowell@ellislab.com> | 2009-03-04 15:49:53 +0100 |
---|---|---|
committer | Robin Sowell <robin.sowell@ellislab.com> | 2009-03-04 15:49:53 +0100 |
commit | 8a54ef21839dd970c85491cddff836b391d48882 (patch) | |
tree | cee3b636397945ae813e8da009f6c8be13f53aa2 | |
parent | 87cbafce2d6803af78714baf8bba64309c01fc33 (diff) |
Altered modify_column and add_column to loop through multiple fields rather than returning after first field.
-rw-r--r-- | system/database/DB_forge.php | 56 |
1 files changed, 38 insertions, 18 deletions
diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index f708910f8..c4597bd1b 100644 --- a/system/database/DB_forge.php +++ b/system/database/DB_forge.php @@ -257,18 +257,28 @@ class CI_DB_forge { } // add field info into field array, but we can only do one at a time - // so only grab the first field in the event there are more then one - $this->add_field(array_slice($field, 0, 1)); + // so we cycle through - if (count($this->fields) == 0) - { - show_error('Field information is required.'); - } + foreach ($field as $k => $v) + { + $this->add_field(array($k => $field[$k])); - $sql = $this->_alter_table('ADD', $this->db->dbprefix.$table, $this->fields, $after_field); + if (count($this->fields) == 0) + { + show_error('Field information is required.'); + } + + $sql = $this->_alter_table('ADD', $this->db->dbprefix.$table, $this->fields, $after_field); - $this->_reset(); - return $this->db->query($sql); + $this->_reset(); + + if ($this->db->query($sql) === FALSE) + { + return FALSE; + } + } + + return TRUE; } // -------------------------------------------------------------------- @@ -318,18 +328,28 @@ class CI_DB_forge { } // add field info into field array, but we can only do one at a time - // so only grab the first field in the event there are more then one - $this->add_field(array_slice($field, 0, 1)); + // so we cycle through - if (count($this->fields) == 0) - { - show_error('Field information is required.'); - } + foreach ($field as $k => $v) + { + $this->add_field(array($k => $field[$k])); - $sql = $this->_alter_table('CHANGE', $this->db->dbprefix.$table, $this->fields); + if (count($this->fields) == 0) + { + show_error('Field information is required.'); + } + + $sql = $this->_alter_table('CHANGE', $this->db->dbprefix.$table, $this->fields); - $this->_reset(); - return $this->db->query($sql); + $this->_reset(); + + if ($this->db->query($sql) === FALSE) + { + return FALSE; + } + } + + return TRUE; } // -------------------------------------------------------------------- |