J'ai actuellement une table document qui comprend plusieurs liaisons avec d'autre table. Elle est liée en many to many avec la table domain (avec une table intermédiaire donc), car un document peut avoir plusieurs domaines. (pas important : La table domain est traduite, elle comprend donc une liaison à une table de traduction). Document est aussi lié en many to many à la table file (avec une table intermédiaire aussi), car un document peut avoir plusieurs fichiers.
Lorsque je veux récupérer tous les documents, je veux aussi récupérer tous leur(s) domaine(s) ainsi que tous leur(s) file(s) :
Voici la requete que j'ai fait :
Select v2_document.title, v2_domain_lang.name As domain_name, v2_file.name AS file_name
From v2_document
Left join v2_domain_document on v2_document.id = v2_domain_document.id_document
Left join v2_domain on v2_domain_document.id_domain = v2_domain.id
Left join v2_domain_lang ON v2_domain.id = v2_domain_lang.reference
Left join v2_language ON v2_domain_lang.language = v2_language.id
Left join v2_file_document on v2_document.id = v2_file_document.id_document
Left join v2_file on v2_file_document.id_file = v2_file.id
Where v2_language.id = 1
Le document à pour titre : titre1Il a comme domaine : asdfsadf, as dfsdaf et aSDasd
et ces files sont : symfony4.doc, symfony3.doc et symfony2.doc
Code : Tout sélectionner
title domain_name file_name
titre1 asdfsadf symfony4.doc
titre1 as dfsdaf symfony4.doc
titre1 aSDasd symfony4.doc
titre1 asDASd symfony4.doc
titre1 asdfsadf symfony3.doc
titre1 as dfsdaf symfony3.doc
titre1 aSDasd symfony3.doc
titre1 asDASd symfony3.doc
titre1 asdfsadf symfony2.doc
titre1 as dfsdaf symfony2.doc
titre1 aSDasd symfony2.doc
titre1 asDASd symfony2.docComment je peux faire au mieux (le moins gourmand et le plus rapide possible) pour avoir au final un tableau de ce type par document. Ceci est un exemple :
<?php
array(title = 'titre1', domain_name => array('domain1', 'domain2', 'domain3', 'domain4'), 'file_name' => array(symfony2.doc, symfony3.doc, symfony4.com);
Merci d'avance pour votre réponse !Tex.