Pagekit\Database\Query\QueryBuilder::whereInSet PHP Method

whereInSet() public method

Creates and adds a "where FIND_IN_SET" equivalent to the query.
public whereInSet ( string $column, mixed $values, boolean $not = false, string $type = null ) : self
$column string
$values mixed
$not boolean
$type string
return self
    public function whereInSet($column, $values, $not = false, $type = null)
    {
        $not = $not ? ' NOT' : '';
        $values = (array) $values;
        if (count($values) === 1 && $this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
            $value = $this->connection->quote(current($values));
            return $this->addWhere("{$not} FIND_IN_SET({$value}, {$column})", [], $type);
        }
        $values = implode('|', (array) $values);
        return $this->addWhere("{$column}{$not} REGEXP " . $this->connection->quote("(^|,)({$values})(\$|,)"), [], $type);
    }