Page 1 of 1

Differences in after_update / after_insert functions

Posted: 2013-02-19 13:52
by Yilmaz
Dear forum,

I use the tablename_after_insert func for sending an email to dedicated user when a new record is inserted. This works very well. I have embedded also a link in the email for the entered record:

Code: Select all

function ap_main_after_insert($data, $memberInfo, &$args){

$id = $data['id'];
$bezirk = $data['district_id'];
... //all other table fields
...
$messageData .= "Bezirk                  : $bezirk  \n";
$messageData .= "Start VK Periode   : $startvk  \n";
... // all other email messages
$messageData .= "Link to record : http://intranet2/werbeplaner/ap_main_view.php?SelectedID=$id\n\n"; //allthough "SelectedID" is written with big capital it works!!!!!!! Otherwise not!!!
In the mail I can see very well the values for example "district_id" and "id" in the URL.

Now I want to do the same issue via after_update func when an existing record is changed/updated. So
I pasted the same code above (with some textual changes in messagedata) in the function tablename_after_update.

Unfortunatelly the result is not the same, i.g. the primary key id is not passed, so that for example the URL has not the record id at the end of the link http://.../SelectedID=123

I found in tablename_dml.php the section where the functions after_insert and after_update are called. There are differences due to the calls for the IDs: "$recID" and "$data['id']".

I tried to replace the $data['id']s in the section for after_update by the $recID like in the section for after_insert, but the result was the same as above (without passing the record id).

I hope I could explain my problem.

What could be the reason?

Many thanks in advance
Yilmaz

Re: Differences in after_update / after_insert functions

Posted: 2013-02-23 06:36
by a.gneady
Try $data['selectedID'] ... this should work.

Re: Differences in after_update / after_insert functions

Posted: 2013-02-26 13:22
by Yilmaz
Dear Ahmad,

thanks for your reply. I tried it with $data['selectedID'] but still no success! Any other idea?

function ap_main_after_insert($data, $memberInfo, &$args){

$id = $data['selectedID'];
$bezirk = $data['district_id'];
... //all other table fields
...