我构建了我的实体的以下部分:
/**
* @var Application_Model_Ticket
*
* @OneToMany(targetEntity="Application_Model_Ticket",mappedBy="contacts_id")
* @JoinColumn(name="id", referencedColumnName="contacts_id")
*/
private $tickets;
public function getTickets() {
return $this->tickets;
}
/**
* @var Application_Model_Contact
*
* @ManyToOne(targetEntity="Application_Model_Contact",cascade={"persist"})
* @JoinColumn(name="contacts_id", referencedColumnName="id")
*/
private $contact;
public function getContact() {
return $this->contact;
}
当我现在尝试以下 Doctrine Code 时:
$this->oQueryBuilder->select('contact','ticket')
->from('Application_Model_Contact', 'contact')
->leftJoin('contact.tickets', 'ticket')
->orderBy('contact.id', 'DESC');
我得到一个 MYSQL 错误。发生以下情况:
FROM contact c0_ LEFT JOIN ORDER BY c0_.id DESC
似乎 Doctrine 没有正确填写 LEFT JOIN。有谁知道,为什么会这样?
更新:
->leftJoin('contact.tickets', 'ticket', 'WITH','contact.id = ticket.contactsId')
给我
LEFT JOIN AND (c0_.id = t1_.contacts_id)