This topic is locked
[SOLVED]

 Inserting a record into another table at export

11/23/2013 7:20:23 PM
PHPRunner General questions
G
g_parry author

Me again - sorry I'm a learner with this. Using PHPRunner 7.0
I am trying to add a record to another table in the "before export record" section.
I am using the following code


global $dal;
$tblEvents = $dal->Table("printed");
$tblEvents->Value["PermitID"]=$values["ID"];
$tblEvents->Value["Address"]=$values["address"];
$tblEvents->Value["Address2"]=$values["address2"];
$tblEvents->Add();


The case in this code is correct but I am getting nothing in the table.
I tried doing it with aa SQL statement too, using the manual - a straight copy and paste, modifying the field names but got a SQL statement error - the error message icluded the data I was tring to copy
I did try doing it using this code


$tblEvents = $dal->Table("printed");

$tblEvents->Value["PermitID"]=$oldvalues["ID"];


This worked for some fields but not the ID field - the structure of the fields are exactly the same except ID is auto incremented and PermitID comes from ID, but it always showed up in the printed table as zero
I guess my question is - is it possible to update another table when a batch of records are exported? If yes, then what am I doing wrong?
Any assistance appreciated

G
g_parry author 11/24/2013

Sorry - the answer was so simple when I worked it out

$sql = "INSERT INTO printed (PermitID) values ('$data[ID]')";

CustomQuery($sql);


It was staring me in the face but the example used text rather than current data so threw me