summaryrefslogtreecommitdiffstats
path: root/system/database
diff options
context:
space:
mode:
authorpporlan <pporlan@gmail.com>2011-12-22 12:15:25 +0100
committerpporlan <pporlan@gmail.com>2011-12-22 12:15:25 +0100
commit2c685fb03a4d4b5a96789b839147191ce8cffacc (patch)
treee468ecb854c4b980e4fbc4fd0488b882144ce256 /system/database
parentfec2f59721af5721ede0d2b60075910a6b646c03 (diff)
Adding $escape parameter to the order_by function, this enables ordering by custom fields
Diffstat (limited to 'system/database')
-rw-r--r--system/database/DB_active_rec.php10
1 files changed, 7 insertions, 3 deletions
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index 41950e7d8..412febfcc 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -830,9 +830,10 @@ class CI_DB_active_record extends CI_DB_driver {
*
* @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 @@ class CI_DB_active_record extends CI_DB_driver {
}
- if (strpos($orderby, ',') !== FALSE)
+ if ((strpos($orderby, ',') !== FALSE) && ($escape === TRUE))
{
$temp = array();
foreach (explode(',', $orderby) as $part)
@@ -863,7 +864,10 @@ class CI_DB_active_record extends CI_DB_driver {
}
else if ($direction != $this->_random_keyword)
{
- $orderby = $this->_protect_identifiers($orderby);
+ if ($escape === TRUE)
+ {
+ $orderby = $this->_protect_identifiers($orderby);
+ }
}
$orderby_statement = $orderby.$direction;