diff --git a/lib/dao/dao.class.php b/lib/dao/dao.class.php index ca2dd5c97a..714a4c3a5b 100755 --- a/lib/dao/dao.class.php +++ b/lib/dao/dao.class.php @@ -1538,7 +1538,12 @@ class sql { $value = trim($value); if(empty($value) or strtolower($value) == 'desc' or strtolower($value) == 'asc') continue; - $orderParse[$key] = "`" . trim($value, '`') . "`"; + $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); }