Doctrine 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();
这是我的架构:
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”子句没有考虑在内。如果邀请 ID 为 3,我仍然有一个“邀请”,并且邀请 ID = 1,
您能帮助我吗?
谢谢你
编辑 解决了!我只需要添加一个?在我的 where 子句中的等号之后:
->where('u.Invites.invitation_id=?', $this->invitation->getId())
I suppose my problem is simple but i can't get it fixed...
Here is my query:
$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();
and here is my 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 }
It seems that my "where" clause in not taking into account. If the invitation_id is 3 i still have an "invite" showing up with invitation_id = 1
Can you help me ?
Thank you
EDIT
SOlved ! i just needed to add a ? after the equal sign in my where clause :
->where('u.Invites.invitation_id=?', $this->invitation->getId())
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)