how to get last inserted id from after_action_edit trigger?
Archived from the Xataface Users forum.
kevinwen — Wed Jan 06, 2010 1:29 am
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?
shannah — Wed Jan 06, 2010 1:38 am
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; }
kevinwen — Wed Jan 06, 2010 11:21 am
Oh, I didn’t know that the Primary key would be popoulated into the $myRecord. Thanks a lot.