前台插件访问
This commit is contained in:
@@ -24,19 +24,28 @@ class Mysql extends Builder
|
||||
* 字段和表名处理
|
||||
* @access protected
|
||||
* @param string $key
|
||||
* @param array $options
|
||||
* @return string
|
||||
*/
|
||||
protected function parseKey($key)
|
||||
protected function parseKey($key, $options = [])
|
||||
{
|
||||
$key = trim($key);
|
||||
if (strpos($key, '$.') && false === strpos($key, '(')) {
|
||||
// JSON字段支持
|
||||
list($field, $name) = explode('$.', $key);
|
||||
$key = 'json_extract(' . $field . ', \'$.' . $name . '\')';
|
||||
} elseif (strpos($key, '.') && !preg_match('/[,\'\"\(\)`\s]/', $key)) {
|
||||
list($table, $key) = explode('.', $key, 2);
|
||||
if (isset($options['alias'][$table])) {
|
||||
$table = $options['alias'][$table];
|
||||
}
|
||||
}
|
||||
if (!preg_match('/[,\'\"\*\(\)`.\s]/', $key)) {
|
||||
$key = '`' . $key . '`';
|
||||
}
|
||||
if (isset($table)) {
|
||||
$key = '`' . $table . '`.' . $key;
|
||||
}
|
||||
return $key;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,15 +43,24 @@ class Pgsql extends Builder
|
||||
* 字段和表名处理
|
||||
* @access protected
|
||||
* @param string $key
|
||||
* @param array $options
|
||||
* @return string
|
||||
*/
|
||||
protected function parseKey($key)
|
||||
protected function parseKey($key, $options = [])
|
||||
{
|
||||
$key = trim($key);
|
||||
if (strpos($key, '$.') && false === strpos($key, '(')) {
|
||||
// JSON字段支持
|
||||
list($field, $name) = explode('$.', $key);
|
||||
$key = $field . '->>\'' . $name . '\'';
|
||||
} elseif (strpos($key, '.')) {
|
||||
list($table, $key) = explode('.', $key, 2);
|
||||
if (isset($options['alias'][$table])) {
|
||||
$table = $options['alias'][$table];
|
||||
}
|
||||
}
|
||||
if (isset($table)) {
|
||||
$key = $table . '.' . $key;
|
||||
}
|
||||
return $key;
|
||||
}
|
||||
|
||||
@@ -48,4 +48,25 @@ class Sqlite extends Builder
|
||||
return 'RANDOM()';
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段和表名处理
|
||||
* @access protected
|
||||
* @param string $key
|
||||
* @param array $options
|
||||
* @return string
|
||||
*/
|
||||
protected function parseKey($key, $options = [])
|
||||
{
|
||||
$key = trim($key);
|
||||
if (strpos($key, '.')) {
|
||||
list($table, $key) = explode('.', $key, 2);
|
||||
if (isset($options['alias'][$table])) {
|
||||
$table = $options['alias'][$table];
|
||||
}
|
||||
}
|
||||
if (isset($table)) {
|
||||
$key = $table . '.' . $key;
|
||||
}
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,17 +61,27 @@ class Sqlsrv extends Builder
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段名分析
|
||||
* 字段和表名处理
|
||||
* @access protected
|
||||
* @param string $key
|
||||
* @param array $options
|
||||
* @return string
|
||||
*/
|
||||
protected function parseKey($key)
|
||||
protected function parseKey($key, $options = [])
|
||||
{
|
||||
$key = trim($key);
|
||||
if (strpos($key, '.') && !preg_match('/[,\'\"\(\)\[\s]/', $key)) {
|
||||
list($table, $key) = explode('.', $key, 2);
|
||||
if (isset($options['alias'][$table])) {
|
||||
$table = $options['alias'][$table];
|
||||
}
|
||||
}
|
||||
if (!is_numeric($key) && !preg_match('/[,\'\"\*\(\)\[.\s]/', $key)) {
|
||||
$key = '[' . $key . ']';
|
||||
}
|
||||
if (isset($table)) {
|
||||
$key = '[' . $table . '].' . $key;
|
||||
}
|
||||
return $key;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user