summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-06-11 19:40:50 +0200
committerAndrey Andreev <narf@bofh.bg>2012-06-11 19:40:50 +0200
commit88cb278a1e52dd7db5b0ebe2037c12f0dd69c0c1 (patch)
tree4fb51dbdb9dd61f7861519a74cacd006bba471c7 /system
parentdf242193f3e785f4c9b802be3432f373fbc34a14 (diff)
Fix issue #1456
Diffstat (limited to 'system')
-rw-r--r--system/database/DB_query_builder.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index b9d77f1fb..7490639dd 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -953,7 +953,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
$part = trim($part);
if ( ! in_array($part, $this->qb_aliased_tables))
{
- $part = $this->protect_identifiers(trim($part));
+ $part = preg_match('/^(.+)\s+(ASC|DESC)$/i', $part, $matches)
+ ? $this->protect_identifiers(rtrim($matches[1])).' '.$matches[2]
+ : $this->protect_identifiers($part);
}
$temp[] = $part;
@@ -963,7 +965,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
}
elseif ($direction !== $this->_random_keyword && $escape === TRUE)
{
- $orderby = $this->protect_identifiers($orderby);
+ $part = preg_match('/^(.+)\s+(ASC|DESC)$/i', $orderby, $matches)
+ ? $this->protect_identifiers(rtrim($matches[1])).' '.$matches[2]
+ : $this->protect_identifiers($orderby);
}
$this->qb_orderby[] = $orderby_statement = $orderby.$direction;