I want to execute and get the results of the following query:
$query = <<<SQL
set @num := 0, @priority := '';
select * from (
select
id, status_ts,
@num := if(@priority = priority, @num + 1, 1) as _row_number,
@priority := priority as priority
FROM ($priority_query) as get_priority
ORDER BY priority DESC, status_ts ASC
) as items where items._row_number <= CEIL(priority);
SQL;
The $sql = $PDO->query($query); $sql->rowCount()
returns 0, there are no result rows. I've tested the query by executing it directly in the DB and it works.