This topic is locked

Auto-update records in multiple tables after edit

1/10/2007 10:58:34 PM
PHPRunner General questions
L
larsonsc author

I am trying to automate a process in my system where if a status of returned is entered, a series of automatic updates happens thus reducing the workload on the end-user. I was trying to do this with an AfterEdit custom code event, but I'm getting a php error of type 2, Missing Argument 1 for AfterEdit(). Any suggestions?

function AfterEdit(&$values, $where)

{

//********** Custom code ************

// put your custom code here
//Define SQL strings

$adopt_update = "update `adoption_records` set `Adoption_Fee_1` = 0, `Adoption_Fee_2` = 0, `Adoption_Fee_3` = 0 where `Intake_ID` = '$values[Intake_ID]' and `Adoption_ID` in (select max(`Adoption_ID`) where `adoption_records`.`Intake_ID` = '$values[Intake_ID]'";

$inventory_update = "update `inventory` set `Status` = 'Available' where `Intake_ID` = '$values[Intake_ID]'";
//Define SQL connection

global $conn;

if($values['Status'] == 'Returned') {

db_query($adopt_update,$conn);

db_query($inventory_update,$conn);

echo "Cat's status reset to available and previous adoption fees zeroed.";

}

else {

}
}


Thanks for any help you can offer.

Sergey Kornilov admin 1/10/2007

AfterEdit event don't have arguments.

L
larsonsc author 1/11/2007

So then how do I access the submitted form values which are usually in $values so that I can do my comparisons? Or is what i am trying to do outside of the scope of an event?

J
Jane 1/11/2007

Shawn,
use BeforeEdit event for your purpose.