*/ /** * * This is a sample application to show how to delete an existing link between * Customers entity instance and Orders Entity Instance. */ require_once 'NorthwindEntities.php'; require_once 'urldef.php'; echo "<h3>Sample9: Delete the link added in Sample8 between a customer entity and Order entity</h3>"; try { $svc = new NorthwindEntities(NORTHWIND_SERVICE_URL); $response = $svc->Customers()->filter("CustomerID eq 'CHAN9'")->Expand('Orders')->Execute(); if (count($response->Result)) { foreach ($response->Result as $customer) { foreach ($customer->Orders as $order) { $svc->DeleteLink($customer, "Orders", $order); $svc->DeleteObject($order); } $svc->DeleteObject($customer); $svc->SaveChanges(); } echo "All Order Links associated with customer with ID CHAN9 has been deleted, also the orders and customer has been deleted"; } else { echo "Customer with CustomerID CHAN9 not found"; } } catch (DataServiceRequestException $ex) { echo 'Error: while running the query ' . $ex->Response->getQuery(); echo "<br/>"; echo $ex->Response->getError(); } catch (ODataServiceException $e) { echo "Error:" . $e->getError() . "<br>" . "Detailed Error:" . $e->getDetailedError();