* fix a bug when order has limit string.
This commit is contained in:
+10
-3
@@ -1529,8 +1529,13 @@ class sql
|
||||
|
||||
$order = str_replace(array('|', '', '_'), ' ', $order);
|
||||
|
||||
/* Add "`" in order. */
|
||||
$orders = explode(',', $order);
|
||||
/* Add "`" in order string. */
|
||||
/* When order has limit string. */
|
||||
$pos = stripos($order, 'limit');
|
||||
$orders = $pos ? substr($order, 0, $pos) : $order;
|
||||
$limit = $pos ? substr($order, $pos) : '';
|
||||
|
||||
$orders = explode(',', $orders);
|
||||
foreach($orders as $i => $order)
|
||||
{
|
||||
$orderParse = explode(' ', trim($order));
|
||||
@@ -1539,15 +1544,17 @@ class sql
|
||||
$value = trim($value);
|
||||
if(empty($value) or strtolower($value) == 'desc' or strtolower($value) == 'asc') continue;
|
||||
$field = trim($value, '`');
|
||||
|
||||
/* such as t1.id field. */
|
||||
if(strpos($value, '.') !== false) list($table, $field) = explode('.', $field);
|
||||
$field = "`$field`";
|
||||
|
||||
$orderParse[$key] = isset($table) ? $table . '.' . $field : $field;
|
||||
unset($table);
|
||||
}
|
||||
$orders[$i] = join(' ', $orderParse);
|
||||
}
|
||||
$order = join(',', $orders);
|
||||
$order = join(',', $orders) . ' ' . $limit;
|
||||
|
||||
$this->sql .= ' ' . DAO::ORDERBY . " $order";
|
||||
return $this;
|
||||
|
||||
Reference in New Issue
Block a user