mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 15:12:48 +08:00
改进驱动的parseKey方法
This commit is contained in:
@@ -82,15 +82,18 @@ class Mysql extends Builder
|
|||||||
/**
|
/**
|
||||||
* 字段和表名处理
|
* 字段和表名处理
|
||||||
* @access protected
|
* @access protected
|
||||||
* @param string $key
|
* @param mixed $key
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function parseKey($key, $options = [], $strict = false)
|
protected function parseKey($key, $options = [], $strict = false)
|
||||||
{
|
{
|
||||||
if (is_int($key)) {
|
if (is_numeric($key)) {
|
||||||
return $key;
|
return $key;
|
||||||
|
} elseif ($key instanceof Expression) {
|
||||||
|
return $key->getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
$key = trim($key);
|
$key = trim($key);
|
||||||
if (strpos($key, '$.') && false === strpos($key, '(')) {
|
if (strpos($key, '$.') && false === strpos($key, '(')) {
|
||||||
// JSON字段支持
|
// JSON字段支持
|
||||||
|
|||||||
@@ -44,12 +44,18 @@ class Pgsql extends Builder
|
|||||||
/**
|
/**
|
||||||
* 字段和表名处理
|
* 字段和表名处理
|
||||||
* @access protected
|
* @access protected
|
||||||
* @param string $key
|
* @param mixed $key
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function parseKey($key, $options = [], $strict = false)
|
protected function parseKey($key, $options = [], $strict = false)
|
||||||
{
|
{
|
||||||
|
if (is_numeric($key)) {
|
||||||
|
return $key;
|
||||||
|
} elseif ($key instanceof Expression) {
|
||||||
|
return $key->getValue();
|
||||||
|
}
|
||||||
|
|
||||||
$key = trim($key);
|
$key = trim($key);
|
||||||
if (strpos($key, '$.') && false === strpos($key, '(')) {
|
if (strpos($key, '$.') && false === strpos($key, '(')) {
|
||||||
// JSON字段支持
|
// JSON字段支持
|
||||||
|
|||||||
@@ -52,12 +52,18 @@ class Sqlite extends Builder
|
|||||||
/**
|
/**
|
||||||
* 字段和表名处理
|
* 字段和表名处理
|
||||||
* @access protected
|
* @access protected
|
||||||
* @param string $key
|
* @param mixed $key
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function parseKey($key, $options = [], $strict = false)
|
protected function parseKey($key, $options = [], $strict = false)
|
||||||
{
|
{
|
||||||
|
if (is_numeric($key)) {
|
||||||
|
return $key;
|
||||||
|
} elseif ($key instanceof Expression) {
|
||||||
|
return $key->getValue();
|
||||||
|
}
|
||||||
|
|
||||||
$key = trim($key);
|
$key = trim($key);
|
||||||
if (strpos($key, '.')) {
|
if (strpos($key, '.')) {
|
||||||
list($table, $key) = explode('.', $key, 2);
|
list($table, $key) = explode('.', $key, 2);
|
||||||
|
|||||||
@@ -73,14 +73,16 @@ class Sqlsrv extends Builder
|
|||||||
/**
|
/**
|
||||||
* 字段和表名处理
|
* 字段和表名处理
|
||||||
* @access protected
|
* @access protected
|
||||||
* @param string $key
|
* @param mixed $key
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function parseKey($key, $options = [], $strict = false)
|
protected function parseKey($key, $options = [], $strict = false)
|
||||||
{
|
{
|
||||||
if (is_int($key)) {
|
if (is_numeric($key)) {
|
||||||
return $key;
|
return $key;
|
||||||
|
} elseif ($key instanceof Expression) {
|
||||||
|
return $key->getValue();
|
||||||
}
|
}
|
||||||
$key = trim($key);
|
$key = trim($key);
|
||||||
if (strpos($key, '.') && !preg_match('/[,\'\"\(\)\[\s]/', $key)) {
|
if (strpos($key, '.') && !preg_match('/[,\'\"\(\)\[\s]/', $key)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user