$criteria->addAsColumn(“lastRow”, MAX(self::ID));给出错误?
我有这个代码:
static public function getLastNewMessage($profile_id)
{
$c = new Criteria();
$subSelect = "rc_message_box_table.profile_id_from NOT IN ( SELECT rc_blocklist_table.profile_id_block FROM rc_blocklist_table WHERE profile_id = $profile_id ) and rc_message_box_table.profile_id_to=$profile_id and opened_once = 0";
$c->add(self::PROFILE_ID_TO, $subSelect, Criteria::CUSTOM);
$c->addAsColumn("lastRow", MAX(self::ID));
//$subSelect2 = "max(rc_message_box_table.id)";
//$c->add(self::ID, $subSelect2, Criteria::CUSTOM);
return self::doSelect($c);
}
并收到此错误:
500 | Internal Server Error | PropelException [wrapped: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS lastRow FROM rc_message_box_table` WHERE rc_message_box_table.profile_id_fro' at line 1]
我只想在 rc_message_box_table 上记录 MAX(自动增量字段),并且该字段是 ID 我也尝试过注释掉的行,但没有任何效果。我不知道如何实现这一目标..请帮忙? 谢谢
i have this code:
static public function getLastNewMessage($profile_id)
{
$c = new Criteria();
$subSelect = "rc_message_box_table.profile_id_from NOT IN ( SELECT rc_blocklist_table.profile_id_block FROM rc_blocklist_table WHERE profile_id = $profile_id ) and rc_message_box_table.profile_id_to=$profile_id and opened_once = 0";
$c->add(self::PROFILE_ID_TO, $subSelect, Criteria::CUSTOM);
$c->addAsColumn("lastRow", MAX(self::ID));
//$subSelect2 = "max(rc_message_box_table.id)";
//$c->add(self::ID, $subSelect2, Criteria::CUSTOM);
return self::doSelect($c);
}
and get this error:
500 | Internal Server Error | PropelException [wrapped: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS lastRow FROM rc_message_box_table` WHERE rc_message_box_table.profile_id_fro' at line 1]
i just want the record of MAX(auto-increment-field) on the rc_message_box_table and this field is ID
i have tried the commented out lines as well but nothing works. i dont know how to achieve this..please help?
thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的SQL中多了一个`,它从哪里来?它就在:
There is an extra ` in your SQL, where does that come from? It is right next to: