Doctrine sql查询,where子句没有考虑在内

时间:2011-07-01 11:39:54

标签: php orm doctrine

我想我的问题很简单,但我无法修复......

这是我的问题:

$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();

这是我的架构:

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,我仍然有“邀请”出现,其中包含invitation_id = 1

你能帮助我吗?

谢谢

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

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

1 个答案:

答案 0 :(得分: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();