diff options
author | Phil Sturgeon <email@philsturgeon.co.uk> | 2012-05-24 18:58:47 +0200 |
---|---|---|
committer | Phil Sturgeon <email@philsturgeon.co.uk> | 2012-05-24 18:58:47 +0200 |
commit | 0bf4e88d935e972fc432b8c3cdaeb5397749b580 (patch) | |
tree | d19b5943d13b06393e118b460aac2ca8d37f8fc6 /system/database | |
parent | 10a4724f7a8113c5e23f113a37709c78406de7f2 (diff) | |
parent | bc602d8b8e125597bfd557949e846ff5a258b858 (diff) |
Merge branch '2.1-stable' of github.com:EllisLab/CodeIgniter into 2.1-stable
Diffstat (limited to 'system/database')
-rw-r--r-- | system/database/DB_active_rec.php | 4 | ||||
-rw-r--r-- | system/database/DB_driver.php | 22 |
2 files changed, 14 insertions, 12 deletions
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 841ede28e..10febb1fc 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -255,7 +255,7 @@ class CI_DB_active_record extends CI_DB_driver { */ public function from($from) { - foreach ((array)$from as $val) + foreach ((array) $from as $val) { if (strpos($val, ',') !== FALSE) { @@ -1647,7 +1647,7 @@ class CI_DB_active_record 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, " ")); diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 6161f149b..c25752824 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1263,15 +1263,20 @@ 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 - $alias = ''; - 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 + { + $alias = ''; } // This is basically a bug fix for queries that use MAX, MIN, etc. @@ -1387,7 +1392,7 @@ class CI_DB_driver { return $item.$alias; } - + // -------------------------------------------------------------------- /** @@ -1395,16 +1400,13 @@ class CI_DB_driver { * * This function is used extensively by every db driver. * - * @access private * @return void */ protected function _reset_select() { - } } - /* End of file DB_driver.php */ -/* Location: ./system/database/DB_driver.php */ +/* Location: ./system/database/DB_driver.php */
\ No newline at end of file |