truncate(); $table = new Product(); $table->truncate(); header("Location: example.php?message=".urlencode("Tables truncated")); exit; } if ( $_POST['newshopper'] ) { $aShopper = new Shopper(); $aShopper->setField('name', $_POST['newshopper'] ); $aShopper->save(); header("Location: example.php?message=".urlencode("New shopper added")); exit; } if ( $_POST['newproduct'] ) { $aProduct = new Product(); $aProduct->setField('name', $_POST['newproduct'] ); $aProduct->save(); header("Location: example.php?message=".urlencode("New product added")); exit; } if ( $_POST['shopper'] && $_POST['product'] ) { $aShopper_Product = new Shopper_Product(); $aShopper_Product->setField('sid', $_POST['shopper']); $aShopper_Product->setField('pid', $_POST['product']); $aShopper_Product->setField('date_added', date("Y-m-d H:i:s")); $aShopper_Product->save(); header("Location: example.php?message=".urlencode("New association added")); exit; } $aShoppers = Shopper::getAll(); $aProducts = Product::getAll(); ?> DbTable Example

DbTable Example

The write up on this lives here: http://www.koopman.me/2008/11/dbtable-and-all-its-glory/

Truncate all data:
Feel free, this is just an example, you can truncate, then enter some data. Keep in mind that another user could be using this at the same time that you are, which will lead to sudden truncation, or more data showing up than what you're entering.
Add shopper:
Name:
Add Product:
Name:
Add Association

List of Shoppers \n"; print " \n"; print " \n"; print "\n"; } ?>
Name Products
".htmlspecialchars($aShopper->getField('name')).""; $products = $aShopper->getProducts(); foreach($products as $aProduct) print htmlspecialchars($aProduct->getField('name')).", "; print "  


List of Products \n"; print " \n"; print " \n"; print "\n"; } ?>
Name Shoppers
".htmlspecialchars($aProduct->getField('name')).""; $shoppers = $aProduct->getShoppers(); foreach($shoppers as $aShopper) print htmlspecialchars($aShopper->getField('name')).", "; print "