This topic is locked

Check after deleting

7/24/2008 1:42:33 AM
PHPRunner General questions
A
allan author

I would like a check is done after a data is deleted. For example, I have `employee` and `customer` table.
In the `customer` table, there is a field that refer to the `employee` ID, so that the admin can know how many customer an employee has.
When an `employee` is deleted, the customer data will contain redundant data that is the removed employee ID.
How can I make a check so that all customers under that employee ID will be set to null?
Thank you.

J
Jane 7/24/2008

Hi,
use Before record deleted event on the Events tab to update `customer` table.

Here is a sample:

global $conn;

$strUpdate = "update `customer` set employeeID=NULL where employeeID=".$deleted_values["ID"];

db_exec($strUpdate,$conn);



where employeeID and ID are your actual field names.

A
allan author 7/25/2008

Thank you