改进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

@@ -89,6 +89,11 @@ class Mysql extends Driver
protected function parseKey(&$key)
{
$key = trim($key);
if (strpos($key, '$.') && false === strpos($key, '(')) {
// JSON字段支持
list($field, $name) = explode($key, '$.');
$key = 'jsn_extract(' . $field . ', \'$.\'.' . $name . ')';
}
if (!preg_match('/[,\'\"\*\(\)`.\s]/', $key)) {
$key = '`' . $key . '`';
}