<?
require_once("classes/User.class.php");
require_once("classes/Cart.class.php");
require_once("classes/Shirt.class.php");
require_once("header.php");
// Getting the persistence manager
$persistence = new Persistence();
// We use phpersistence to get the cart object.
$currentCart = $persistence->getById("Cart", 1);
// we load the Shirt object
$shirt = $persistence->getById("Shirt", 4);
// product 0 in the products array is replaced.
$currentCart->products[0] = $shirt;
// What about adding a new phone number to the user?
$currentCart->user->telephones[] = "03 04 05 06 07";
// cart is saved
$persistence->saveOrUpdate($currentCart);
/**
* Notice that the phone number was updated also in the database, while the cart was saved.
* This happened because the objects are linked,
* and because this link is configured : "cascade" => "save-update"
* in the persistence.conf.php file.
*/
// Lets look at the cart
// Logger::debug prints a dump of the object
Logger::debug($currentCart);
?>