改进model类order方法

添加json类型支持 支持json字段查询例如 $map['user$.name'] = 'thinkphp'
escapeString方法采用PDO::quote方法
This commit is contained in:
thinkphp
2015-11-21 12:06:00 +08:00
parent fb145db8c6
commit fa17feddf0
7 changed files with 92 additions and 74 deletions

View File

@@ -100,6 +100,16 @@ class Sqlsrv extends Driver
*/
protected function parseOrder($order)
{
$array = [];
foreach ($order as $key => $val) {
if (is_numeric($key)) {
$array[] = $this->parseKey($val);
} else {
$sort = in_array(strtolower(trim($val)), ['asc', 'desc']) ? ' ' . $val : '';
$array[] = $this->parseKey($key) . ' ' . $sort;
}
}
$order = implode(',', $array);
return !empty($order) ? ' ORDER BY ' . $order : ' ORDER BY rand()';
}