Please enable JavaScript to view this site.

Navigation: Advanced topics > Events > Sample events > Database

PHPrunner32x32     PHPRunner manual


Check for related records before deleting the current one

Scroll Prev Next More

 

Before deleting a record in the Orders table, check for related items in the OrderDetails table. Add the following code to the List page: Before record deleted event.

 

Note: Change red values to match your project.

 

// Parameters:
// where - string with WHERE clause pointing to record to be deleted.
global $dal;
$tblOrder = $dal->Table("OrderDetails");
$rs = $tblOrder->Query("OrderID=".$deleted_values["OrderID"],"");
$data = db_fetch_array($rs);
if($data)
return false;
else
return true;

See also:

Data Access Layer

DAL method: TableName()

DAL method: Query

Database API

Check if specific record exists

Master-details relationship between tables

 

Created with Help+Manual 7 and styled with Premium Pack Version 3 © by EC Software