{ foreach ($products as $p) { /* @var $p ProductModel */ echo $p->getPurchaseCost() . "\t-\t" . $p->getDescription() . "\n"; } } // query by identifier echo ' -> get product with product id 948933' . "\n"; $product = ProductModel::findById($db, 948933); echo $product->getDescription() . "\n"; // query by example echo ' -> get all products with product code HW' . "\n"; // define sorting $sort = array(new DSC(ProductModel::FIELD_DESCRIPTION, DSC::ASC), new DSC(ProductModel::FIELD_PURCHASE_COST, DSC::ASC)); $example = new ProductModel(); $example->setProductCode('HW'); $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);