donglin7979 2013-03-06 00:13
浏览 426
已采纳

Propel(PostgreSQL)语法错误在“。”附近。

I have a database set up (work in progress with currently only two tables: user and email) and integrated with Propel. When registering a user I check to make sure that the email does not already exist (either as a current email in the email table or an original email in the user database).

To do this simply with propel, I use the following:

if(EmailQuery::create()->filterByCurrent(TRUE)->findOneByEmailAddress($email) != NULL) {
    // email address being used currently
} else if(UserQuery::create()->findOneByOriginalEmail($email) != NULL) {
    // email address claimed on account already
}

The first query works fine, but the second query generates and error: Syntax error: 7 ERROR: syntax error at or near "." The SQL query generated by Propel looks like the following:

SELECT user.id, user.original_email, user.password, user.accept_terms, user.paid, user.customer_id, user.trial_end, user.created_at, user.updated_at, user.ip_address FROM user WHERE user.original_email=:p1 LIMIT 1

If I copy and paste this into phpPgAdmin, it returns the same error (and points to each . in between user and the column). I am new to PostgreSQL, is there some syntax piece I am missing? All other Propel query builders I have used worked without a hitch.

  • 写回答

1条回答 默认 最新

  • douyu9433 2013-03-06 00:47
    关注

    Answer from minitech's comment.

    user is a reserved ANSI SQL term. Either SELECT "user".id FROM "user" has to be used or table must be renamed. I renamed the table to account, and all is well.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大