summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
Diffstat (limited to 'system')
-rw-r--r--system/database/DB_forge.php1
-rw-r--r--system/database/drivers/mssql/mssql_driver.php47
-rw-r--r--system/database/drivers/mysqli/mysqli_driver.php3
-rw-r--r--system/database/drivers/oci8/oci8_driver.php14
-rw-r--r--system/database/drivers/postgre/postgre_driver.php2
-rw-r--r--system/database/drivers/sqlite/sqlite_driver.php14
6 files changed, 58 insertions, 23 deletions
diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php
index 7febb72c2..cd468bc6a 100644
--- a/system/database/DB_forge.php
+++ b/system/database/DB_forge.php
@@ -40,7 +40,6 @@ class CI_DB_forge {
// Assign the main database object to $this->db
$CI =& get_instance();
$this->db =& $CI->db;
-
log_message('debug', "Database Forge Class Initialized");
}
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index 4cf444088..8e12a2d21 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -430,16 +430,51 @@ class CI_DB_mssql_driver extends CI_DB {
* @param boolean only affect the first word
* @return mixed the item with backticks
*/
- function _protect_identifiers($item, $affect_spaces = TRUE, $first_word_only = FALSE)
+ function _protect_identifiers($item, $first_word_only = FALSE)
{
- // MSSQL doesn't use backticks
- if (strpos($item, '.') !== FALSE)
+ if (is_array($item))
{
- $aliased_tables = implode(".",$this->ar_aliased_tables).'.';
- $table_name = substr($item, 0, strpos($item, '.')+1);
- $item = (strpos($aliased_tables, $table_name) !== FALSE) ? $item = $item : $this->dbprefix.$item;
+ $escaped_array = array();
+
+ foreach($item as $k=>$v)
+ {
+ $escaped_array[$this->_protect_identifiers($k)] = $this->_protect_identifiers($v, $first_word_only);
+ }
+
+ return $escaped_array;
+ }
+
+ // This function may get "item1 item2" as a string, and so
+ // we may need ""item1" "item2"" and not ""item1 item2""
+ if (ctype_alnum($item) === FALSE)
+ {
+ if (strpos($item, '.') !== FALSE)
+ {
+ $aliased_tables = implode(".",$this->ar_aliased_tables).'.';
+ $table_name = substr($item, 0, strpos($item, '.')+1);
+ $item = (strpos($aliased_tables, $table_name) !== FALSE) ? $item = $item : $this->dbprefix.$item;
+ }
+
+ // This function may get "field >= 1", and need it to return ""field" >= 1"
+ $lbound = ($first_word_only === TRUE) ? '' : '|\s|\(';
+
+ $item = preg_replace('/(^'.$lbound.')([\w\d\-\_]+?)(\s|\)|$)/iS', '$1"$2"$3', $item);
+ }
+ else
+ {
+ return "\"{$item}\"";
}
+ $exceptions = array('AS', '/', '-', '%', '+', '*');
+
+ foreach ($exceptions as $exception)
+ {
+
+ if (stristr($item, " \"{$exception}\" ") !== FALSE)
+ {
+ $item = preg_replace('/ "('.preg_quote($exception).')" /i', ' $1 ', $item);
+ }
+ }
return $item;
}
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index b6d1cba77..31c27117c 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -96,7 +96,8 @@ class CI_DB_mysqli_driver extends CI_DB {
*/
function db_set_charset($charset, $collation)
{
- return @mysqli_query($this->conn_id, "SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'");
+ // TODO - add support if needed
+ return TRUE;
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index 7aab37e82..8f63c25a5 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -556,7 +556,7 @@ class CI_DB_oci8_driver extends CI_DB {
}
// This function may get "item1 item2" as a string, and so
- // we may need "`item1` `item2`" and not "`item1 item2`"
+ // we may need ""item1" "item2"" and not ""item1 item2""
if (ctype_alnum($item) === FALSE)
{
if (strpos($item, '.') !== FALSE)
@@ -566,14 +566,14 @@ class CI_DB_oci8_driver extends CI_DB {
$item = (strpos($aliased_tables, $table_name) !== FALSE) ? $item = $item : $this->dbprefix.$item;
}
- // This function may get "field >= 1", and need it to return "`field` >= 1"
+ // This function may get "field >= 1", and need it to return ""field" >= 1"
$lbound = ($first_word_only === TRUE) ? '' : '|\s|\(';
- $item = preg_replace('/(^'.$lbound.')([\w\d\-\_]+?)(\s|\)|$)/iS', '$1`$2`$3', $item);
+ $item = preg_replace('/(^'.$lbound.')([\w\d\-\_]+?)(\s|\)|$)/iS', '$1"$2"$3', $item);
}
else
{
- return "`{$item}`";
+ return "\"{$item}\"";
}
$exceptions = array('AS', '/', '-', '%', '+', '*');
@@ -581,9 +581,9 @@ class CI_DB_oci8_driver extends CI_DB {
foreach ($exceptions as $exception)
{
- if (stristr($item, " `{$exception}` ") !== FALSE)
+ if (stristr($item, " \"{$exception}\" ") !== FALSE)
{
- $item = preg_replace('/ `('.preg_quote($exception).')` /i', ' $1 ', $item);
+ $item = preg_replace('/ "('.preg_quote($exception).')" /i', ' $1 ', $item);
}
}
return $item;
@@ -608,7 +608,7 @@ class CI_DB_oci8_driver extends CI_DB {
$tables = array($tables);
}
- return '('.implode(', ', $tables).')';
+ return implode(', ', $tables);
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index cac0ecb60..a32c37ed8 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -493,7 +493,7 @@ class CI_DB_postgre_driver extends CI_DB {
$tables = array($tables);
}
- return '('.implode(', ', $tables).')';
+ return implode(', ', $tables);
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index 5290edeea..b6cb460b1 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -404,7 +404,7 @@ class CI_DB_sqlite_driver extends CI_DB {
{
if (stristr($table, '.'))
{
- $table = preg_replace("/\./", "`.`", $table);
+ $table = preg_replace("/\./", ".", $table);
}
return $table;
@@ -437,7 +437,7 @@ class CI_DB_sqlite_driver extends CI_DB {
}
// This function may get "item1 item2" as a string, and so
- // we may need "`item1` `item2`" and not "`item1 item2`"
+ // we may need "item1 item2" and not "item1 item2"
if (ctype_alnum($item) === FALSE)
{
if (strpos($item, '.') !== FALSE)
@@ -447,14 +447,14 @@ class CI_DB_sqlite_driver extends CI_DB {
$item = (strpos($aliased_tables, $table_name) !== FALSE) ? $item = $item : $this->dbprefix.$item;
}
- // This function may get "field >= 1", and need it to return "`field` >= 1"
+ // This function may get "field >= 1", and need it to return "field >= 1"
$lbound = ($first_word_only === TRUE) ? '' : '|\s|\(';
- $item = preg_replace('/(^'.$lbound.')([\w\d\-\_]+?)(\s|\)|$)/iS', '$1`$2`$3', $item);
+ $item = preg_replace('/(^'.$lbound.')([\w\d\-\_]+?)(\s|\)|$)/iS', '$1$2$3', $item);
}
else
{
- return "`{$item}`";
+ return "{$item}";
}
$exceptions = array('AS', '/', '-', '%', '+', '*');
@@ -462,9 +462,9 @@ class CI_DB_sqlite_driver extends CI_DB {
foreach ($exceptions as $exception)
{
- if (stristr($item, " `{$exception}` ") !== FALSE)
+ if (stristr($item, " {$exception} ") !== FALSE)
{
- $item = preg_replace('/ `('.preg_quote($exception).')` /i', ' $1 ', $item);
+ $item = preg_replace('/ ('.preg_quote($exception).') /i', ' $1 ', $item);
}
}
return $item;