このクエリを実行すると:
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
)
)
正しいキーを表すには連想配列が必要です!
私のSQLでは私はそうしますが
select id as current
select id as previous
select id as next
current
それらはすべて???として出てきます
何か案は?