This topic is locked
[SOLVED]

 Insert Current ID into new Record

6/9/2010 6:36:54 PM
PHPRunner General questions
T
Tempus_Erus author

Hi,
I need to get the current ID (Primary Key)of a record of just created - say 45 and insert it into another table. This key (45) will have everything related to in the new field that has the ID 45 assosiated with it.
I have basically produced an invoiceing system (almost) and the new table would be called invoice items.
Any PHP ideas welcome. I have no doubt overlooked the obvious!
thanks in advance.

N
nix386 6/9/2010

I'm no expert and could be wrong but something like this should do the trick?

You'll need to change the code to suit your application.
Add Page>After Record Added Event.



global $conn;

//********** Insert ID into another table ************
$strSQLInsert = "insert into another_table (ID, OtherValues,OtherValues) values ('".$values["ID"]."','$OtherValues','$OtherValues')";

db_exec($strSQLInsert,$conn);




Hi,
I need to get the current ID (Primary Key)of a record of just created - say 45 and insert it into another table. This key (45) will have everything related to in the new field that has the ID 45 assosiated with it.
I have basically produced an invoiceing system (almost) and the new table would be called invoice items.
Any PHP ideas welcome. I have no doubt overlooked the obvious!
thanks in advance.

J
Jane 6/10/2010

Hi,
keys values are stored in the $keys array in the After record added event on the Eventstab.

You can use following variable in your code:

$keys["FieldName"]



where FieldName is your actual field name.
Please note field names are case sensitive here.

T
Tempus_Erus author 6/10/2010



Hi,
keys values are stored in the $keys array in the After record added event on the Eventstab.

You can use following variable in your code:

$keys["FieldName"]



where FieldName is your actual field name.
Please note field names are case sensitive here.


Once again the forum delivers! Once again I was overcomplicating the issue!
Thanks to all.