This commit is contained in:
2021-03-26 19:18:43 +08:00
parent 78cf1b2a9a
commit 0825725abe
+22 -1
View File
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Database\Condition;
use JetBrains\PhpStorm\Pure;
use Snowflake\Abstracts\BaseObject;
use Snowflake\Core\Str;
@@ -54,8 +55,28 @@ abstract class Condition extends BaseObject
}
$this->value = $values;
} 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);
}
}
}