2020-08-31 12:38:32 +08:00
|
|
|
<?php
|
2020-10-29 18:17:25 +08:00
|
|
|
declare(strict_types=1);
|
2020-08-31 12:38:32 +08:00
|
|
|
|
|
|
|
|
namespace Database\Condition;
|
|
|
|
|
|
|
|
|
|
use Database\ActiveQuery;
|
2020-12-17 14:09:14 +08:00
|
|
|
use Exception;
|
2021-02-24 18:34:57 +08:00
|
|
|
use JetBrains\PhpStorm\Pure;
|
2020-08-31 12:38:32 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class InCondition
|
|
|
|
|
* @package Database\Condition
|
|
|
|
|
*/
|
|
|
|
|
class InCondition extends Condition
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return string
|
2020-12-17 14:09:14 +08:00
|
|
|
* @throws Exception
|
2020-08-31 12:38:32 +08:00
|
|
|
*/
|
2021-02-24 18:34:57 +08:00
|
|
|
#[Pure] public function builder(): string
|
2020-08-31 12:38:32 +08:00
|
|
|
{
|
2021-02-24 18:34:57 +08:00
|
|
|
if (is_array($this->value)) {
|
2021-02-26 11:03:57 +08:00
|
|
|
return sprintf('%s IN (%s)', $this->column, implode(',', $this->value));
|
2021-03-26 19:09:54 +08:00
|
|
|
} else {
|
|
|
|
|
return sprintf('%s IN (%s)', $this->column, $this->value);
|
2020-08-31 12:38:32 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|