You have to maintain the relationship yourself. So say you wanted to delete a user from table User. You would have to write two sql statements; one to delete the user from User and one two delete the related records in Address. So you could do something in PHP like this: (assumes that there is a db connection already established)
PHP Code:
function deleteUser($id) {
$global $dbconnection;
if(!$dbconnection) {
return 0; // return false
}
$sql = "DELETE FROM User WHERE UserID = $id";
$result = mysql_query($sql);
if(!$result) {
return 0; // return false
}
$sql = "DELETE FROM Address WHERE UserID=$id";
$result = mysql_query($sql);
return $result;
}
This function will return non-zero (true) if the deletion occured or 0 (false) if an error occured.
Bookmarks