- $i = 0;
- $coll = '';
- $mask = '';
- foreach ($params as $key => $value) {
- if ($i === 0) {
- $coll = $coll . "$key";
- $mask = $mask . "'" . "$value" . "'";
- } else {
- $coll = $coll . ", $key";
- $mask = $mask . ", '" . "$value" . "'";
- }
- $i++;
- }
+ $coll = implode(',', array_keys($params));
+ $mask = ':' . implode(',:', array_keys($params));
WITH RECURSIVE `cte` AS (
SELECT `id`, `parent_id`, `comment`,
CAST(RIGHT(CONCAT('0000', `id`), 4) AS CHAR(256)) AS `path`
FROM `comments`
WHERE `parent_id` = 0
UNION
SELECT `c`.`id`, `c`.`parent_id`, `c`.`comment`,
CONCAT(`cte`.`path`, '/', RIGHT(CONCAT('0000', `c`.`id`), 4)) AS `path`
FROM `cte`
JOIN `comments` AS `c` ON `c`.`parent_id` = `cte`.`id`
)
SELECT *
FROM `cte`
ORDER BY `path`
year_end < 2014 OR year_start > 2018
NOT(year_end < 2014 OR year_start > 2018)
!(a | b) === (!a) & (!b)
и приведём условие к виду:year_end >= 2014 AND year_start <= 2018