2011-07-01 55 views
1

我想我的问题很简单,但我不能把它修好......主义的SQL查询,WHERE子句不考虑

这里是我的查询:

$this->invites = Doctrine_Query::create() 
     ->from('Utilisateur u') 
     ->LeftJoin('u.Invites i ON i.utilisateur_id = u.id') 
     ->where('u.Invites.invitation_id=', $this->invitation->getId()) 
     ->execute(); 

,这里是我的schema:

Invites: 
    columns: 
    invitation_id: {type: integer, notnull: true } 
    utilisateur_id: {type: integer, notnull: true } 
    relations: 
    Utilisateur: {onDelete: CASCADE, local: utilisateur_id, foreign: id} 
    Invitation: {onDelete: CASCADE, local: invitation_id, foreign: id, class: Invitation, refClass: Invites} 

Utilisateur: 
actAs: { Timestampable: ~ } 
columns: 
    email: {type: string(255), notnull: true } 
    password: {type: string(255), notnull: true } 
    facebook: {type: integer(11), notnull: true } 
    smartphone: {type: string(128), notnull: true } 
    prenom: {type: string(255), notnull: true } 
    nom: {type: string(255), notnull: true } 
    daten: {type: timestamp, notnull: true } 
    sexe: {type: boolean, notnull: true, default: 0} 
    date: {type: timestamp, notnull: true } 

看来我的“where”子句没有考虑到。如果invitation_id是3,我仍然有一个“invite”出现在invitation_id = 1

你能帮助我吗?

谢谢

编辑 解决了!我只需要添加一个?在我的where子句中的等号之后:

 ->where('u.Invites.invitation_id=?', $this->invitation->getId()) 

回答

1
$this->invites = Doctrine_Query::create() 
    ->from('Utilisateur u') 
    ->LeftJoin('u.Invites i ON i.utilisateur_id = u.id') 
    ->where('u.Invites.invitation_id = ?', $this->invitation->getId()) 
    ->execute();