私の問題の説明を簡単にするために、3 つのテーブルからデータを選択するために小さな SQL クエリを実行したとしましょう。
SELECT blockTitre, ChampsType, ChampsNom
FROM form_builder
LEFT JOIN block_champs
ON formBuilderBId = blockId
RIGHT JOIN ajout_champs
ON ChampsId = formBuilderChId
結果を var_dump すると、次のようになります。
array (size=6)
0 =>
object(stdClass)[8]
public 'blockTitre' => string 'Misc' (length=4)
public 'ChampsType' => string 'submit' (length=6)
public 'ChampsNom' => string 'submit' (length=6)
1 =>
object(stdClass)[9]
public 'blockTitre' => string 'Misc' (length=4)
public 'ChampsType' => string 'hidden' (length=6)
public 'ChampsNom' => string 'page' (length=4)
2 =>
object(stdClass)[10]
public 'blockTitre' => string 'Information général' (length=21)
public 'ChampsType' => string 'text' (length=4)
public 'ChampsNom' => string 'email' (length=5)
3 =>
object(stdClass)[11]
public 'blockTitre' => string 'Information général' (length=21)
public 'ChampsType' => string 'text' (length=4)
public 'ChampsNom' => string 'prenom' (length=6)
4 =>
object(stdClass)[12]
public 'blockTitre' => string 'Information général' (length=21)
public 'ChampsType' => string 'text' (length=4)
public 'ChampsNom' => string 'age' (length=3)
5 =>
object(stdClass)[13]
public 'blockTitre' => string 'Misc' (length=4)
public 'ChampsType' => string 'text' (length=4)
public 'ChampsNom' => string 'nommm' (length=5)
私が欲しいのは、結果をblockTitreで再グループ化することです。
SQLステートメントを試しましたGROUP BY
が、2行しか返されません(ロジックだと思います)!
blockTitreでグループ化されたすべての行を取得する方法をマスターしてください 。
前もって感謝します。
編集 :
次のようなものを取得する必要があります:
0 =>
'blockTitre' => string 'Misc'
'ChampsType' => string 'submit'
'ChampsNom' => string 'submit'
'ChampsType' => string 'text'
'ChampsNom' => string 'nommm'
'ChampsType' => string 'hidden'
'ChampsNom' => string 'page'
1 =>
'blockTitre' => string 'Information général'
'ChampsType' => string 'text'
'ChampsNom' => string 'email'
'ChampsType' => string 'text'
'ChampsNom' => string 'prenom'
'ChampsType' => string 'text'
'ChampsNom' => string 'age'