$products = ProductModel::findByExample($db, $example, true, $sort); listProducts($products); // query with filter echo ' -> get all products with a purchase cost of at least 1000' . "\n"; $filter = new DFC(ProductModel::FIELD_PURCHASE_COST, 1000, DFC::NOT | DFC::SMALLER); $products = ProductModel::findByFilter($db, $filter, true, $sort); listProducts($products); echo ' -> get all products with a purchase cost smallther than 1000 and the description containg Computer' . "\n"; $filter = array(new DFC(ProductModel::FIELD_PURCHASE_COST, 1000, DFC::SMALLER), new DFC(ProductModel::FIELD_DESCRIPTION, 'Computer', DFC::CONTAINS)); $products = ProductModel::findByFilter($db, $filter); listProducts($products); // query with SQL $sql = "SELECT * FROM PRODUCT WHERE DESCRIPTION LIKE '%Sound%'"; echo ' -> get by SQL: ' . $sql . "\n"; $products = ProductModel::findBySql($db, $sql); listProducts($products); // insert new product $product = new ProductModel(); $product->setProductId(123)->setManufacturerId(123)->setProductCode('HW')->setPurchaseCost(1234567890)->setQuantityOnHand(1)->setMarkup(1234567891)->setAvailable('TRUE')->setDescription('Test Product'); $product->insertIntoDatabase($db); // update product $product->setPurchaseCost(100); $product->setMarkup(120); $product->setQuantityOnHand(200); // get changed fields var_dump($product->getFieldsValuesChanged()); $product->updateToDatabase($db); // delete product $product->deleteFromDatabase($db); // dom functions echo $product->toDOM()->saveXML();
<li><a href="shop.php">Shop</a></li> <li><a href="cart.php">Cart</a></li> </ul> <ul class="pull-right"> <li><a href="accessories.html">Accessories</a></li> <li><a href="AboutUs.html">About Us</a></li> </ul> </div> </div> <div class="table"> <table align="center" border="2"> <tr> <?php require_once "connection.php"; listProducts(); ?> <!-- <tr> <th><img src="Products/Prod1.jpg" alt="SegWay" height="275" width="350"/></th> <th><img src="Products/Prod2.jpg" alt="SegWay" height="275" width="350"/></th> <th><img src="Products/Prod3.jpg" alt="SegWay" height="275" width="350"/></th> </tr> <tr> <td>Classic Black <strong>฿5500 </strong></td> <td>Classic Blue <strong>฿5500 </strong></td> <td>Classic White <strong>฿5500 </strong></td> </tr> <tr> <th><img src="Products/Prod4.jpg" alt="SegWay" height="275" width="350"/></th>
} elseif ($type & Upgrade) { echo "Upgrade\n"; } elseif ($type & Ability) { echo "Ability\n"; } foreach (Product::$all as $product) { if (($product->type & $type) == $type && !empty($product->name)) { echo $product . "\n"; } } echo "\n"; } // Protoss listProducts(Protoss | Structure); listProducts(Protoss | Morph); listProducts(Protoss | Unit); listProducts(Protoss | Upgrade); listProducts(Protoss | Ability); // Terran listProducts(Terran | Structure); listProducts(Terran | Morph); listProducts(Terran | Unit); listProducts(Terran | Upgrade); listProducts(Terran | Ability); // Zerg listProducts(Zerg | Structure); listProducts(Zerg | Morph); listProducts(Zerg | Unit); listProducts(Zerg | Upgrade); listProducts(Zerg | Ability);