This commit is contained in:
2023-12-12 15:35:35 +08:00
parent 510a13e3da
commit e2c0f62532
32 changed files with 922 additions and 1095 deletions
+15 -15
View File
@@ -10,20 +10,20 @@ namespace Database\Condition;
class HashCondition extends Condition
{
/**
* @return string
* @throws \Exception
*/
public function builder(): string
{
$array = [];
if (count($this->value) < 1) {
throw new \Exception('Builder data by a empty array.');
}
foreach ($this->value as $key => $value) {
$array[] = $key . '=' . addslashes($value);
}
return implode(' AND ', $array);
}
/**
* @return string
* @throws
*/
public function builder(): string
{
$array = [];
if (count($this->value) < 1) {
throw new \Exception('Builder data by a empty array.');
}
foreach ($this->value as $key => $value) {
$array[] = $key . '=' . addslashes($value);
}
return implode(' AND ', $array);
}
}
+12 -13
View File
@@ -3,7 +3,6 @@ declare(strict_types=1);
namespace Database\Condition;
use Exception;
use JetBrains\PhpStorm\Pure;
/**
@@ -14,17 +13,17 @@ class InCondition extends Condition
{
/**
* @return string
* @throws Exception
*/
#[Pure] public function builder(): string
{
if (is_array($this->value)) {
return $this->column . ' IN (' . implode(',', $this->value) . ')';
} else {
return $this->column . ' IN (' . $this->value . ')';
}
}
/**
* @return string
* @throws
*/
#[Pure] public function builder(): string
{
if (is_array($this->value)) {
return $this->column . ' IN (' . implode(',', $this->value) . ')';
} else {
return $this->column . ' IN (' . $this->value . ')';
}
}
}
+6 -2
View File
@@ -12,9 +12,13 @@ class JsonCondition extends Condition
{
public function builder()
{
/**
* @return bool
*/
public function builder(): bool
{
// TODO: Implement builder() method.
return \json_validate($this->value);
}
}
+12 -12
View File
@@ -13,17 +13,17 @@ class NotInCondition extends Condition
{
/**
* @return string|null
* @throws \Exception
*/
#[Pure] public function builder(): ?string
{
if (!is_array($this->value)) {
throw new \Exception('Builder data by a empty string. need array');
}
$value = '\'' . implode('\',\'', $this->value) . '\'';
return '`' . $this->column . '` not in(' . $value . ')';
}
/**
* @return string|null
* @throws
*/
#[Pure] public function builder(): ?string
{
if (!is_array($this->value)) {
throw new \Exception('Builder data by a empty string. need array');
}
$value = '\'' . implode('\',\'', $this->value) . '\'';
return '`' . $this->column . '` not in(' . $value . ')';
}
}