diff options
Diffstat (limited to 'system/database')
-rw-r--r-- | system/database/DB_forge.php | 17 | ||||
-rw-r--r-- | system/database/DB_query_builder.php | 5 | ||||
-rw-r--r-- | system/database/DB_utility.php | 2 | ||||
-rw-r--r-- | system/database/drivers/cubrid/cubrid_forge.php | 15 | ||||
-rw-r--r-- | system/database/drivers/mysql/mysql_forge.php | 15 | ||||
-rw-r--r-- | system/database/drivers/mysqli/mysqli_forge.php | 15 | ||||
-rw-r--r-- | system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php | 15 | ||||
-rw-r--r-- | system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php | 15 |
8 files changed, 83 insertions, 16 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; diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 9bd535b0e..e77fba63d 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -903,11 +903,12 @@ abstract class CI_DB_query_builder extends CI_DB_driver { } is_bool($escape) OR $escape = $this->_protect_identifiers; - $prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) - ? $this->_group_get_type('') : $this->_group_get_type($type); foreach ($field as $k => $v) { + $prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) + ? $this->_group_get_type('') : $this->_group_get_type($type); + $v = $this->escape_like_str($v); if ($side === 'none') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index a32fd4455..c4140aef3 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -146,7 +146,7 @@ abstract class CI_DB_utility { if ($query !== FALSE) { $query = $query->result_array(); - return current($res); + return current($query); } return FALSE; diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index 9a7cdb805..2a737c5ed 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -179,13 +179,24 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * @param string $table (ignored) * @return string */ - protected function _process_indexes($table = NULL) + protected function _process_indexes($table) { $sql = ''; 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; diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php index 1e9145e4f..f4394c685 100644 --- a/system/database/drivers/mysql/mysql_forge.php +++ b/system/database/drivers/mysql/mysql_forge.php @@ -175,13 +175,24 @@ class CI_DB_mysql_forge extends CI_DB_forge { * @param string $table (ignored) * @return string */ - protected function _process_indexes($table = NULL) + protected function _process_indexes($table) { $sql = ''; 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; diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php index 1a6e284ee..f29ea5ade 100644 --- a/system/database/drivers/mysqli/mysqli_forge.php +++ b/system/database/drivers/mysqli/mysqli_forge.php @@ -175,13 +175,24 @@ class CI_DB_mysqli_forge extends CI_DB_forge { * @param string $table (ignored) * @return string */ - protected function _process_indexes($table = NULL) + protected function _process_indexes($table) { $sql = ''; 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; diff --git a/system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php b/system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php index cb7d9e697..ebf4b15d6 100644 --- a/system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php +++ b/system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php @@ -179,13 +179,24 @@ class CI_DB_pdo_cubrid_forge extends CI_DB_pdo_forge { * @param string $table (ignored) * @return string */ - protected function _process_indexes($table = NULL) + protected function _process_indexes($table) { $sql = ''; 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; diff --git a/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php b/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php index 85d9445d3..5a6de6b2d 100644 --- a/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php +++ b/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php @@ -189,13 +189,24 @@ class CI_DB_pdo_mysql_forge extends CI_DB_pdo_forge { * @param string $table (ignored) * @return string */ - protected function _process_indexes($table = NULL) + protected function _process_indexes($table) { $sql = ''; 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; |