Working on multiple active records bug

In short, I’m unable to do this:

$AR1 = new AR1;


$AR2 = new AR2;

$AR2->save(); //Once this line is executed, $AR1 loses it’s primary key.


        $Post->attributes = array(

            'id_board' =>$_POST['board'],

            'id_member' => $_POST['user'],

            'poster_name' => Yii::app()->user->name,

            'modified_name' => $Member->real_name,

            'subject' => htmlentities($_POST['subject']),

            'body' => nl2br(htmlentities($_POST['text'])),            

            'poster_email' => $Member->email_address,

            'poster_ip' => $_SERVER['REMOTE_ADDR'],

            'poster_time' => time()




        $Topic = new ForumTopics;

        $Topic->attributes = array(

            'id_board' => $_POST['board'],

            'id_first_msg' => $Post->id_msg,

            'id_last_msg' => $Post->id_msg,

            'id_member_started' => $_POST['user'],

            'id_member_updated' => $_POST['user'],

            'approved' => 1


        $Topic->save(); //<--THIS LINE CAUSES ERROR POSTED BELOW-->


CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '54298' for key 1UPDATE `smf_messages` SET `id_topic`=:yp0, `id_board`=:yp1, `poster_time`=:yp2, `id_member`=:yp3, `id_msg_modified`=:yp4, `smileys_enabled`=:yp5, `modified_time`=:yp6, `icon`=:yp7, `approved`=:yp8, `poster_name`=:yp9, `modified_name`=:yp10, `subject`=:yp11, `body`=:yp12, `poster_email`=:yp13, `poster_ip`=:yp14, `id_msg`=:yp15 WHERE `smf_messages`.`id_msg` IS NULL

EDIT: This seems to fix it;



Yes, this is a bug in 1.1.0. I already fixed it in SVN. Thanks.