Files
kiri-core/Database/Condition/LikeCondition.php
T

29 lines
447 B
PHP
Raw Normal View History

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 Snowflake\Core\Str;
/**
* Class LikeCondition
* @package Database\Condition
*/
class LikeCondition extends Condition
{
2020-10-29 18:17:25 +08:00
public string $pos = '';
2020-08-31 12:38:32 +08:00
/**
* @return string
*/
2020-12-17 14:09:14 +08:00
public function builder(): string
2020-08-31 12:38:32 +08:00
{
if (!is_string($this->value)) {
$this->value = array_shift($this->value);
}
2021-02-24 18:34:57 +08:00
return $this->column . ' LIKE \'%' . addslashes($this->value) . '%\'';
2020-08-31 12:38:32 +08:00
}
}