当我执行此查询时:
select id as current from events where date = '{$result['date']}'
union all
(select id as previous from events where date < '{$result['date']}' order by date desc limit 1)
union all
(select id as next from events where date > '{$result['date']}' order by date asc limit 1)
它选择日期所在的 ID、$result['date]
低于该日期的日期和高于该日期的日期。
所以在我的 php 代码中,我需要一个像这样的数组:
Array
(
[0] => Array
(
[current] => 6
)
[1] => Array
(
[previous] => 5
)
[2] => Array
(
[next] => 7
)
)
但是,数组的结果如下:
Array
(
[0] => Array
(
[current] => 6
)
[1] => Array
(
[current] => 5
)
[2] => Array
(
[current] => 7
)
)
我需要 assoc 数组来描述正确的键!
即使在我的 SQL 中我做
select id as current
select id as previous
select id as next
他们都出来了current
???
有任何想法吗?