Page 1 of 1

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

Posted: Fri Sep 16, 2011 6:09 am
by helloise
i have this code:

Code: Select all

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);
    }
but get 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 also tried the commented out lines and it is not working
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

Re: Propel $criteria->addAsColumn(“lastRow”,MAX(self::ID)) e

Posted: Sat Sep 17, 2011 5:51 am
by VladSun