eee
This commit is contained in:
+15
-15
@@ -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
@@ -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 . ')';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 . ')';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user