Files
kiri-databases/Condition/HashCondition.php
T

30 lines
531 B
PHP
Raw Normal View History

2022-01-09 03:49:51 +08:00
<?php
declare(strict_types=1);
namespace Database\Condition;
/**
* Class HashCondition
* @package Yoc\db\condition
*/
class HashCondition extends Condition
{
/**
* @return string
2023-04-07 18:23:27 +08:00
* @throws \Exception
2022-01-09 03:49:51 +08:00
*/
public function builder(): string
{
$array = [];
2023-04-07 18:23:27 +08:00
if (count($this->value) < 1) {
throw new \Exception('Builder data by a empty array.');
2022-01-09 03:49:51 +08:00
}
foreach ($this->value as $key => $value) {
2023-04-07 18:23:27 +08:00
$array[] = $key . '=' . addslashes($value);
2022-01-09 03:49:51 +08:00
}
return implode(' AND ', $array);
}
}