Jump to content

$criteria->addAsColumn(“lastRow”, MAX(self::ID)); gives error


Recommended Posts

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.