私はこの選択を書きました
SELECT
t1.id t1_id, t1.title t1_title, t1.subtitle t1_subtitle, t1.content t1_content,
t3.picture t3_picture
FROM
webcms_cms_content t1
INNER JOIN webcms_mod_galleries_pictures t3
ON t1.gallery_id = t3.gallery_id
WHERE t1.structure_id =3
AND t1.status=1
AND t1.flag=1
ORDER BY t1.newsdatum DESC
そして、この小さな php スニペット:
$i=0;
while($db->next_record()) {
$con[$db->get_content('t1_id')]['id'] = $db->get_content('t1_id');
$con[$db->get_content('t1_id')]['title'] = $db->get_content('t1_title');
$con[$db->get_content('t1_id')]['link'] = $db->get_content('t1_subtitle');
$con[$db->get_content('t1_id')]['content'] = $db->get_content('t1_content');
$con[$db->get_content('t1_id')]['pics'][$i] = $db->get_content('t3_picture');
$i++;
}
次のような配列を返します。
array
8 =>
array
'id' => string '8' (length=1)
'title' => string 'Studios (2 Personen)' (length=20)
'link' => string '350.- bis 550.- ' (length=16)
'content' => string 'Gemütlich eichenmöbiliertes Studio bestehend aus einem Wohnraum mit zwei Schrankbetten, Fernseher mit Radio, Telefon, Wireless, Küche mit Backofen, Wasserkocher und Kaffeemaschine, Bad/Dusche, WC und auf der Südseite mit Terasse und Matterhornblick.' (length=269)
'pics' =>
array
0 => string 'p186rgot3ohd612pljp8m8h12d74' (length=28)
1 => string 'p186rgot3o1cso2nj4h81e47ils2' (length=28)
2 => string 'p186rgl7f84r9h671jkr1vctip61' (length=28)
3 => string 'p186rgot3o6fjk7c1j1nc1p1ukj1' (length=28)
4 => string 'p186rhu0bjuq9tfe1ca13ll1qte1' (length=28)
これで問題ありませんが、もっと多くのことが必要です :) これが可能かどうかはわかりません (これは私が書いた最初の大きな SQL クエリです)。
- t3.picture にエントリがないという「要素」の欠落原因が 1 つあります。
1.1なので、pics配列を空にしたいだけです
- t1.newsdatum DESC で注文し、t3.rang ASC で注文する必要があります。
これは1回のクエリで可能ですか? 複数のクエリを使用しても問題ありませんが、1 つだけにしたいと思います。
sqlfiddleを作成しました
あなたの時間と提案を前もってありがとう!