2020-08-31 12:38:32 +08:00
|
|
|
<?php
|
2020-10-29 18:17:25 +08:00
|
|
|
declare(strict_types=1);
|
2021-02-24 18:34:57 +08:00
|
|
|
|
2020-08-31 12:38:32 +08:00
|
|
|
namespace Database\Condition;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class HashCondition
|
|
|
|
|
* @package Yoc\db\condition
|
|
|
|
|
*/
|
|
|
|
|
class HashCondition extends Condition
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2020-12-17 14:09:14 +08:00
|
|
|
public function builder(): string
|
2020-08-31 12:38:32 +08:00
|
|
|
{
|
|
|
|
|
$array = [];
|
|
|
|
|
if (empty($this->value)) {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
foreach ($this->value as $key => $value) {
|
|
|
|
|
if ($value === null) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2021-03-26 15:10:50 +08:00
|
|
|
$array[] = sprintf("%s = '%s'", $key, addslashes($value));
|
2020-08-31 12:38:32 +08:00
|
|
|
}
|
|
|
|
|
return implode(' AND ', $array);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|