变更
This commit is contained in:
@@ -18,7 +18,7 @@ class DefaultCondition extends Condition
|
||||
*/
|
||||
#[Pure] public function builder(): string
|
||||
{
|
||||
return sprintf('%s %s %s', $this->column, $this->opera, addslashes($this->value));
|
||||
return $this->column . ' ' . $this->opera . ' ' . addslashes($this->value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,17 +12,16 @@ class HashCondition extends Condition
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function builder(): string
|
||||
{
|
||||
$array = [];
|
||||
if (empty($this->value)) {
|
||||
return '';
|
||||
if (count($this->value) < 1) {
|
||||
throw new \Exception('Builder data by a empty array.');
|
||||
}
|
||||
foreach ($this->value as $key => $value) {
|
||||
if (is_null($value)) continue;
|
||||
|
||||
$array[] = sprintf("%s = '%s'", $key, addslashes($value));
|
||||
$array[] = $key . '=' . addslashes($value);
|
||||
}
|
||||
return implode(' AND ', $array);
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ class InCondition extends Condition
|
||||
#[Pure] public function builder(): string
|
||||
{
|
||||
if (is_array($this->value)) {
|
||||
return sprintf('%s IN (%s)', $this->column, implode(',', $this->value));
|
||||
return $this->column . ' IN (' . implode(',', $this->value) . ')';
|
||||
} else {
|
||||
return sprintf('%s IN (%s)', $this->column, $this->value);
|
||||
return $this->column . ' IN (' . $this->value . ')';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,11 +15,12 @@ class NotInCondition extends Condition
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
* @throws \Exception
|
||||
*/
|
||||
#[Pure] public function builder(): ?string
|
||||
{
|
||||
if (!is_array($this->value)) {
|
||||
return null;
|
||||
throw new \Exception('Builder data by a empty string. need array');
|
||||
}
|
||||
$value = '\'' . implode('\',\'', $this->value) . '\'';
|
||||
return '`' . $this->column . '` not in(' . $value . ')';
|
||||
|
||||
@@ -21,7 +21,7 @@ class OrCondition extends Condition
|
||||
*/
|
||||
#[Pure] public function builder(): string
|
||||
{
|
||||
return sprintf('(%s) OR %s', implode(' AND ', $this->oldParams), addslashes($this->value));
|
||||
return '(' . implode(' AND ', $this->oldParams) . ') OR ' . addslashes($this->value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user