From d6057485408fab0caaca75ef78434d8077eaadd9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 3 Apr 2012 14:07:31 +0300 Subject: Fix issue #14 --- system/database/drivers/mysqli/mysqli_forge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database/drivers/mysqli') diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php index 8cf0ae1fd..a1caf5cfb 100644 --- a/system/database/drivers/mysqli/mysqli_forge.php +++ b/system/database/drivers/mysqli/mysqli_forge.php @@ -42,7 +42,7 @@ class CI_DB_mysqli_forge extends CI_DB_forge { */ public function _create_database($name) { - return 'CREATE DATABASE '.$name; + return 'CREATE DATABASE '.$name.' CHARACTER SET '.$this->db->char_set.' COLLATE '.$this->db->dbcollat; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 97f3697b6c1c220a32d8e63c5da636e9d725dd8a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 5 Apr 2012 12:44:36 +0300 Subject: Added a default _insert_batch() method instead of requiring each driver to define it and fixed 2 issues related to it --- system/database/drivers/mysqli/mysqli_driver.php | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'system/database/drivers/mysqli') diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index 47b0449d6..6a82ed493 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -513,24 +513,6 @@ class CI_DB_mysqli_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Insert_batch statement - * - * Generates a platform-specific insert string from the supplied data - * - * @param string the table name - * @param array the insert keys - * @param array the insert values - * @return string - */ - protected function _insert_batch($table, $keys, $values) - { - return 'INSERT INTO '.$table.' ('.implode(', ', $keys).') VALUES '.implode(', ', $values); - } - - // -------------------------------------------------------------------- - - /** * Replace statement * -- cgit v1.2.3-24-g4f1b From 65d537ce35cc01c2f31144d695725255322cb792 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 5 Apr 2012 14:11:41 +0300 Subject: Replaced driver instances of _insert() with one in CI_DB_active_record --- system/database/drivers/mysqli/mysqli_driver.php | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'system/database/drivers/mysqli') diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index 6a82ed493..3a835b439 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -496,23 +496,6 @@ class CI_DB_mysqli_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Insert statement - * - * Generates a platform-specific insert string from the supplied data - * - * @param string the table name - * @param array the insert keys - * @param array the insert values - * @return string - */ - protected function _insert($table, $keys, $values) - { - return 'INSERT INTO '.$table.' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')'; - } - - // -------------------------------------------------------------------- - /** * Replace statement * -- cgit v1.2.3-24-g4f1b From 975034d50ed7b3c530631ba3e24a73e33be24eff Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 5 Apr 2012 15:09:55 +0300 Subject: Added a default _update() method to CI_DB_active_record --- system/database/drivers/mysqli/mysqli_driver.php | 27 ------------------------ 1 file changed, 27 deletions(-) (limited to 'system/database/drivers/mysqli') diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index 3a835b439..565e3f4c0 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -513,33 +513,6 @@ class CI_DB_mysqli_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Update statement - * - * Generates a platform-specific update string from the supplied data - * - * @param string the table name - * @param array the update data - * @param array the where clause - * @param array the orderby clause - * @param array the limit clause - * @return string - */ - protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE) - { - foreach ($values as $key => $val) - { - $valstr[] = $key.' = '.$val; - } - - return 'UPDATE '.$table.' SET '.implode(', ', $valstr) - .(($where != '' && count($where) > 0) ? ' WHERE '.implode(' ', $where) : '') - .(count($orderby) > 0 ? ' ORDER BY '.implode(', ', $orderby) : '') - .( ! $limit ? '' : ' LIMIT '.$limit); - } - - // -------------------------------------------------------------------- - /** * Update_Batch statement * -- cgit v1.2.3-24-g4f1b From a3bca8f8c1e4cca5d763cbfe043999cbfd07cd21 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 5 Apr 2012 15:17:25 +0300 Subject: Replaced driver instances of _replace() with one in CI_DB_active_record --- system/database/drivers/mysqli/mysqli_driver.php | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'system/database/drivers/mysqli') diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index 565e3f4c0..26a77aa75 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -496,23 +496,6 @@ class CI_DB_mysqli_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Replace statement - * - * Generates a platform-specific replace string from the supplied data - * - * @param string the table name - * @param array the insert keys - * @param array the insert values - * @return string - */ - protected function _replace($table, $keys, $values) - { - return 'REPLACE INTO '.$table.' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')'; - } - - // -------------------------------------------------------------------- - /** * Update_Batch statement * -- cgit v1.2.3-24-g4f1b From a6fe36eb42e5d8df8336f8c711ff8a6e0ee509e7 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 5 Apr 2012 16:00:32 +0300 Subject: Added a default _truncate() method to CI_DB_active_record --- system/database/drivers/mysqli/mysqli_driver.php | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'system/database/drivers/mysqli') diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index 26a77aa75..00bc726c5 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -539,23 +539,6 @@ class CI_DB_mysqli_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Truncate statement - * - * Generates a platform-specific truncate string from the supplied data - * If the database does not support the truncate() command - * This function maps to "DELETE FROM table" - * - * @param string the table name - * @return string - */ - protected function _truncate($table) - { - return 'TRUNCATE '.$table; - } - - // -------------------------------------------------------------------- - /** * Delete statement * -- cgit v1.2.3-24-g4f1b From ea09a8a5552f2aacdeab0c88a605fe44047ebd0a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 6 Apr 2012 20:50:07 +0300 Subject: Renamed _escape_identifiers() to escape_identifiers() and moved it to CI_DB_driver --- system/database/drivers/mysqli/mysqli_driver.php | 37 ----------------------- system/database/drivers/mysqli/mysqli_forge.php | 4 +-- system/database/drivers/mysqli/mysqli_utility.php | 4 +-- 3 files changed, 4 insertions(+), 41 deletions(-) (limited to 'system/database/drivers/mysqli') diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index 00bc726c5..50e213641 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -438,43 +438,6 @@ class CI_DB_mysqli_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Escape the SQL Identifiers - * - * This function escapes column and table names - * - * @param string - * @return string - */ - public function _escape_identifiers($item) - { - if ($this->_escape_char == '') - { - return $item; - } - - foreach ($this->_reserved_identifiers as $id) - { - if (strpos($item, '.'.$id) !== FALSE) - { - $item = str_replace('.', $this->_escape_char.'.', $item); - - // remove duplicates if the user already included the escape - return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $this->_escape_char.$item); - } - } - - if (strpos($item, '.') !== FALSE) - { - $item = str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item); - } - - // remove duplicates if the user already included the escape - return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $this->_escape_char.$item.$this->_escape_char); - } - - // -------------------------------------------------------------------- - /** * From Tables * diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php index a1caf5cfb..4b6939e2a 100644 --- a/system/database/drivers/mysqli/mysqli_forge.php +++ b/system/database/drivers/mysqli/mysqli_forge.php @@ -148,7 +148,7 @@ class CI_DB_mysqli_forge extends CI_DB_forge { $sql .= 'IF NOT EXISTS '; } - $sql .= $this->db->_escape_identifiers($table).' ('.$this->_process_fields($fields); + $sql .= $this->db->escape_identifiers($table).' ('.$this->_process_fields($fields); if (count($primary_keys) > 0) { @@ -187,7 +187,7 @@ class CI_DB_mysqli_forge extends CI_DB_forge { */ public function _drop_table($table) { - return 'DROP TABLE IF EXISTS '.$this->db->_escape_identifiers($table); + return 'DROP TABLE IF EXISTS '.$this->db->escape_identifiers($table); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php index 4d7002e78..cb3f86b8b 100644 --- a/system/database/drivers/mysqli/mysqli_utility.php +++ b/system/database/drivers/mysqli/mysqli_utility.php @@ -56,7 +56,7 @@ class CI_DB_mysqli_utility extends CI_DB_utility { */ public function _optimize_table($table) { - return 'OPTIMIZE TABLE '.$this->db->_escape_identifiers($table); + return 'OPTIMIZE TABLE '.$this->db->escape_identifiers($table); } // -------------------------------------------------------------------- @@ -71,7 +71,7 @@ class CI_DB_mysqli_utility extends CI_DB_utility { */ public function _repair_table($table) { - return 'REPAIR TABLE '.$this->db->_escape_identifiers($table); + return 'REPAIR TABLE '.$this->db->escape_identifiers($table); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b