I have an add page that when I save updates some other tables. It works if all of the fields are completed but fails if any of the key fields are empty, I don't want to make these fields required so need to incorporate a where clause to stop the transfer if there is no data.
global $dal;
$tblEvents = $dal->Table("tblTestVehicles");
$tblEvents->Value["vclPersonID"]=$values["appPersonID"];
$tblEvents->Value["vclPermitID"]=$values["ID"];
$tblEvents->Value["vclVehicleID"]=$values["vclVehicleID"];
$tblEvents->Value["vclMake"]=$values["vclMake"];
$tblEvents->Value["vclModel"]=$values["vclModel"];
$tblEvents->Value["vclColour"]=$values["vclColour"];
$tblEvents->Value["vclType"]=$values["vclType"];
$tblEvents->Add();
$tblEvents = $dal->Table("tblTestVehicles");
$tblEvents->Value["vclPersonID"]=$values["appPersonID"];
$tblEvents->Value["vclPermitID"]=$values["ID"];
$tblEvents->Value["vclVehicleID"]=$values["vclVehicleID2"];
$tblEvents->Value["vclMake"]=$values["vclMake2"];
$tblEvents->Value["vclModel"]=$values["vclModel2"];
$tblEvents->Value["vclColour"]=$values["vclColour2"];
$tblEvents->Value["vclType"]=$values["vclType2"];
$tblEvents->Add();
return true;
I have also tried the following but get errors
global $conn;
$strSQLInsert = "INSERT INTO tblTestVehicles (vclPermitID, vclVehicleID, vclPersonID, vclColour, vclMake, vclModel,vclType)
VALUES (".$keys['ID'].",'".
$values["vclVehicleID2"]."','".$values["apnPersonID2"]."','".$values["vclColour2"]."','".$values["vclMake2"]."','".$values["vclModel2"]."','".$values["vclType2"]."') WHERE ".$keys["vclVehicleID2"]" > '1';
db_exec($strSQLInsert,$conn);
The inserts work finw until I add a where statement I need to add Where vclVehicleID2 is not empty on the second insert
I've been struggling with this for hours and would appreciate any help