helloise Posted September 16, 2011 Share Posted September 16, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/247266-criteria-addascolumn%E2%80%9Clastrow%E2%80%9D-maxselfid-gives-error/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.