[Doctrine] Relation n - n
Bonjour,
J'essai de réaliser une relation n-n sous doctrine mais rien ni fait. J'ai pourtant suivi pas mal de tuto, mais lorsque j'essai d'exploiter mes tables, pas de relation.
Je suis parti d'un fichier yaml pour générer ma table MySQL :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| entreprise:
actAs:
SoftDelete:
Timestampable:
created:
type: date
format: d-m-Y
update:
type: date
format: d-m-Y
Sluggable:
fields: [intitule]
Searchable:
fields: [intitule]
columns:
id:
type: integer(8)
primary: true
autoincrement: true
identifiant:
type: string(100)
notnull: true
password:
type: string(20)
notnull: true
intitule:
type: string(255)
notnull: true
relations:
RCategorie:
class: categorie
local: entreprise_id
foreign: categorie_id
refClass: entreprise_categorie
foreignAlias: entreprises
categorie:
columns:
id:
type: integer(4)
primary: true
autoincrement: true
titre:
type: string(100)
notnull: true
relations:
REntreprise:
class: entreprise
local: categorie_id
foreign: entreprise_id
refClass: entreprise_categorie
foreignAlias: categories
entreprise_categorie:
columns:
entreprise_id:
type: integer(8)
primary: true
categorie_id:
type: integer(4)
primary: true |
La base ce crée bien, et lorsque je regarde les relations de la table "entreprise_categorie" dans phpMyAdmin, tout est ok.
Ensuite dans mon code Php j'essai une requête de ce type (ressortir toutes les entreprises d'une catégorie) :
Code:
1 2 3 4 5
| $categorie = $_GET['categorie'];
$queryEntreprisesByCategorie = Doctrine_Query::create()->select('e.intitule')
->from('entreprise e')
->leftJoin('entreprise_categorie ec')
->where('ec.categorie_id='.$categorie); |
Mais un :
Code:
echo('<pre>'.$queryEntreprisesByCategorie->getSqlQuery().'</pre>');
Me donne juste ça :
Code:
SELECT e.id AS e__id, e.intitule AS e__intitule FROM entreprise e, entreprise_categorie e2 WHERE (e2.categorie_id = 1 AND (e.deleted_at IS NULL))
Il n'y a pas de JOIN dans le FROM... Faut-il laisser Doctrine gérer les ID peut-être ? Un idée ? :)
Merci de votre aide !