This is a mariadb query. How can i execute these three 'set' query along with the fourth one.
1) set @month_count = :periodicity_id;
2) set @kpi_cat = :kpi_category_id;
3) set @kpi_status = :kpi_status_id;
4) WITH RECURSIVE cte (id, name, parent_id, level, path, subtenant_type) AS (
select id, name, parent_id, CAST('' AS CHAR(10)), cast(id as char(200)), subtenant_type_id
from subtenant where
parent_id = $parent_id
UNION ALL
select s.id, s.name, s.parent_id, CONCAT(c.level, '-'), CONCAT(c.path, ',', s.id), s.subtenant_type_id
from subtenant s
inner join cte c on s.parent_id = c.id
)
----------------------
-----------------------------------//query continuing
I have tried PUTTING ALL THE QUERIES TOGETHER LIKE THIS..BUT RESULTS ARE WRONG
$this->src("mysql")
->query("set @month_count = :periodicity_id;")
->query("set @kpi_cat = :kpi_category_id;")
->query("set @active_status = :kpi_activation_status_id;")
->query(" set @kpi_status = :kpi_status_id;")
->query("WITH RECURSIVE cte (id, name, parent_id, level, path, subtenant_type) AS (
select id, name, parent_id, CAST('' AS CHAR(10)), cast(id as char(200)), subtenant_type_id
from subtenant where
parent_id = $parent_id
UNION ALL
select s.id, s.name, s.parent_id, CONCAT(c.level, '-'), CONCAT(c.path, ',', s.id), s.subtenant_type_id
from subtenant s
inner join cte c on s.parent_id = c.id
)
---------------------
-------------------------//query continuing
->params(array(":sector_id"=>$this->params["sector"],":mtp_id"=>$this->params["mtp"],":periodicity_id"=>$this->params["periodicity"],":kpi_category_id"=>$this->params["kpi_category"],":kpi_activation_status_id"=>$this->params["kpi_activation_status"],":kpi_status_id"=>$this->params["kpi_status"] ))
->pipe($this->dataStore('user_details'));