Page 1 of 1

how to get last inserted id from after_action_edit trigger?

PostPosted: Wed Jan 06, 2010 1:29 am
by kevinwen
I want to duplicate an record in edit mode when user checks this option. What I does is get the current record in after_action_edit() and remove the primary key in the record object then $record->save(). The problem is when I save it(new record was created), the application is redirected to the original record, not the one that was just duplicated. Does anyone know how to do that? The only solution I can think of is to use mysql_insert_id() to get the id. It's better to use the Dataface_Record object to accomplish it. Can it do that?

Re: how to get last inserted id from after_action_edit trigger?

PostPosted: Wed Jan 06, 2010 1:38 am
by shannah
Why not just redirect from inside your after_action_edit trigger?

Code: Select all
function after_action_edit($params=array()){
    header("Location: ".$myduplicateRecord->getURL('-action=edit'));
    exit;
}

Re: how to get last inserted id from after_action_edit trigger?

PostPosted: Wed Jan 06, 2010 11:21 am
by kevinwen
Oh, I didn't know that the Primary key would be popoulated into the $myRecord. Thanks a lot.