Merge pull request #809 from pporlan/patch-1
Adding $escape parameter to the order_by function, this enables ordering...
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index 41950e7..412febf 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -830,9 +830,10 @@
*
* @param string
* @param string direction: asc or desc
+ * @param bool enable field name escaping
* @return object
*/
- public function order_by($orderby, $direction = '')
+ public function order_by($orderby, $direction = '', $escape = TRUE)
{
if (strtolower($direction) == 'random')
{
@@ -845,7 +846,7 @@
}
- if (strpos($orderby, ',') !== FALSE)
+ if ((strpos($orderby, ',') !== FALSE) && ($escape === TRUE))
{
$temp = array();
foreach (explode(',', $orderby) as $part)
@@ -863,7 +864,10 @@
}
else if ($direction != $this->_random_keyword)
{
- $orderby = $this->_protect_identifiers($orderby);
+ if ($escape === TRUE)
+ {
+ $orderby = $this->_protect_identifiers($orderby);
+ }
}
$orderby_statement = $orderby.$direction;