[Doctrine] Exécution d'une jointure externe
Bonjour,
J'ai un petit problème lorsque je veux joindre deux tables avec Doctrine :
Code:
1 2 3 4 5 6 7
| <?php
$q = Doctrine_Query::create()
->select('n.titre, n.auteur, n.contenu, c.auteur, c.contenu')
->from('news n')
->leftjoin('commentaires c')
->execute();
?> |
Mais ce code produit une exception Doctrine_Hydrator_Exception, dont je ne parviens pas à saisir la cause :
Citation:
"commentaires" with an alias of "c" in your query does not reference the parent component it is related to.
Je vous joins les modèles de mes classes :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| <?php
abstract class DoctrineNews extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('news');
$this->hasColumn('id', 'integer', 8,
array('type' => 'integer',
'length' => 8,
'primary' => true,
'autoincrement' => true));
$this->hasColumn('titre', 'string', 100);
$this->hasColumn('auteur', 'string', 100);
$this->hasColumn('contenu', 'string', 4000);
}
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| <?php
abstract class DoctrineCommentaires extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('commentaires');
$this->hasColumn('c_id', 'integer', 8,
array('type' => 'integer',
'length' => 8,
'primary' => true,
'autoincrement' => true));
$this->hasColumn('id_news', 'integer', 8);
$this->hasColumn('auteur', 'string', 100);
$this->hasColumn('contenu', 'string', 4000);
}
} |
Merci d'avance