diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-11-25 16:20:04 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-11-25 16:20:04 +0100 |
commit | 3545102a83a70a42876148037bec05f4bb32913e (patch) | |
tree | 26287b8a6655f4b2b225608e09b49954c26c15c5 /system/database/DB_forge.php | |
parent | b8c4e48a8e9399c971dc32475b2fcb1f847667f9 (diff) |
Fix #2027
Diffstat (limited to 'system/database/DB_forge.php')
-rw-r--r-- | system/database/DB_forge.php | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index bb1ee4809..59c3baf8b 100644 --- a/system/database/DB_forge.php +++ b/system/database/DB_forge.php @@ -402,7 +402,7 @@ abstract class CI_DB_forge { // Are indexes created from within the CREATE TABLE statement? (e.g. in MySQL) if ($this->_create_table_keys === TRUE) { - $columns .= $this->_process_indexes(); + $columns .= $this->_process_indexes($table); } // _create_table will usually have the following format: "%s %s (%s\n)" @@ -962,14 +962,25 @@ abstract class CI_DB_forge { * @param string $table * @return string */ - protected function _process_indexes($table = NULL) + protected function _process_indexes($table) { $table = $this->db->escape_identifiers($table); $sqls = array(); for ($i = 0, $c = count($this->keys); $i < $c; $i++) { - if ( ! isset($this->fields[$this->keys[$i]])) + if (is_array($this->keys[$i])) + { + for ($i2 = 0, $c2 = count($this->keys[$i]); $i2 < $c2; $i2++) + { + if ( ! isset($this->fields[$this->keys[$i][$i2]])) + { + unset($this->keys[$i][$i2]); + continue; + } + } + } + elseif ( ! isset($this->fields[$this->keys[$i]])) { unset($this->keys[$i]); continue; |