我要执行并获取以下查询的结果:
$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;
这个 $sql = $PDO->query($query); $sql->rowCount()
返回0,没有结果行。我已经通过直接在数据库中执行它来测试了这个查询,它可以正常工作。
1条答案
按热度按时间ktecyv1j1#
方法是进行多重查询,改变
set
至select
然后正确地遍历结果。pdo公司
迈斯克利