summaryrefslogtreecommitdiffstats
path: root/system/database
diff options
context:
space:
mode:
authorGreg Aker <greg@gregaker.net>2011-12-25 06:32:59 +0100
committerGreg Aker <greg@gregaker.net>2011-12-25 06:32:59 +0100
commit25a056c8d9c8dcf73ff1cd1d29cb25f238a5e76b (patch)
tree24cf24be1fa69fca29043f9806714016d3983700 /system/database
parentf57162f95bea9c6386b663c0368816115158d792 (diff)
parent2c685fb03a4d4b5a96789b839147191ce8cffacc (diff)
Merge pull request #809 from pporlan/patch-1
Adding $escape parameter to the order_by function, this enables ordering...
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;