summaryrefslogtreecommitdiffstats
path: root/system/database
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-06-10 05:18:14 +0200
committerAndrey Andreev <narf@bofh.bg>2012-06-10 05:18:14 +0200
commit5a257187c4ca09ea61c19999bf061cec3f224cc2 (patch)
tree56f5208bac5394f37c16e62625a149b3746d8e23 /system/database
parent92aa67cf67292b20cfb8f18fc9e24b7408620355 (diff)
Merge branch 2.1-stable into develop
Diffstat (limited to 'system/database')
-rw-r--r--system/database/DB_driver.php10
-rw-r--r--system/database/DB_query_builder.php2
2 files changed, 7 insertions, 5 deletions
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 65f1f18d0..f5a7e2ac0 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -1307,14 +1307,16 @@ abstract class CI_DB_driver {
}
// Convert tabs or multiple spaces into single spaces
- $item = preg_replace('/[\t ]+/', ' ', $item);
+ $item = preg_replace('/\s+/', ' ', $item);
// If the item has an alias declaration we remove it and set it aside.
// Basically we remove everything to the right of the first space
- if (strpos($item, ' ') !== FALSE)
+ if (preg_match('/^([^\s]+) (AS )*(.+)$/i', $item, $matches))
{
- $alias = strstr($item, ' ');
- $item = substr($item, 0, - strlen($alias));
+ $item = $matches[1];
+
+ // Escape the alias
+ $alias = ' '.$matches[2].$this->escape_identifiers($matches[3]);
}
else
{
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index 5d0a2ae2c..3b45bbada 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -1985,7 +1985,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
if (strpos($table, ' ') !== FALSE)
{
// if the alias is written with the AS keyword, remove it
- $table = preg_replace('/ AS /i', ' ', $table);
+ $table = preg_replace('/\s+AS\s+/i', ' ', $table);
// Grab the alias
$table = trim(strrchr($table, ' '));