how to get last inserted id from after_action_edit trigger?

A place for users and developers of the Xataface to discuss and receive support.

how to get last inserted id from after_action_edit trigger?

Postby 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?
kevinwen
 
Posts: 109
Joined: Mon Dec 28, 2009 3:44 pm

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

Postby 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;
}
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

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

Postby 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.
kevinwen
 
Posts: 109
Joined: Mon Dec 28, 2009 3:44 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 5 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved