改名
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
namespace Database\Condition;
|
namespace Database\Condition;
|
||||||
|
|
||||||
|
|
||||||
|
use JetBrains\PhpStorm\Pure;
|
||||||
use Snowflake\Abstracts\BaseObject;
|
use Snowflake\Abstracts\BaseObject;
|
||||||
use Snowflake\Core\Str;
|
use Snowflake\Core\Str;
|
||||||
|
|
||||||
@@ -54,8 +55,28 @@ abstract class Condition extends BaseObject
|
|||||||
}
|
}
|
||||||
$this->value = $values;
|
$this->value = $values;
|
||||||
} else {
|
} else {
|
||||||
$this->value = is_numeric($params) ? $params : '\'' . $params . '\'';
|
$this->value = $this->checkIsSqlString($params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $params
|
||||||
|
* @return int|string
|
||||||
|
*/
|
||||||
|
#[Pure] private function checkIsSqlString($params): int|string
|
||||||
|
{
|
||||||
|
if (is_numeric($params)) {
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
$check = strtolower(substr($params, 0, 6));
|
||||||
|
if (in_array($check, ['update', 'select', 'insert', 'delete'])) {
|
||||||
|
return $params;
|
||||||
|
} else {
|
||||||
|
return sprintf('\'%s\'', $params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user