Added more filtering to Preorder/Index

This commit is contained in:
Frank Schubert
2023-04-24 13:26:55 +02:00
parent 9f96fc4cf1
commit f89909014a
7 changed files with 33 additions and 8 deletions

View File

@@ -90,11 +90,25 @@ class ProductModel {
}
public static function getFirst() {
public static function getFirst($filter = false) {
$db = FronkDB::singleton();
//var_dump($db);exit;
$where = self::getSqlFilter($filter);
$res = $db->select("Product", "*", "$where ORDER BY producttech_id, name LIMIT 1");
$sql = "SELECT Product.* FROM `Product`
LEFT JOIN Productgroup ON (Productgroup.id = Product.id)
LEFT JOIN ProductAttribute ON (ProductAttribute.product_id = Product.id)
LEFT JOIN Producttech ON (Product.producttech_id = Producttech.id)
LEFT JOIN ProducttechAttribute ON (ProducttechAttribute.producttech_id = Producttech.id)
WHERE $where
GROUP BY Product.id
ORDER BY Productgroup.name,Producttech.name,Product.name LIMIT 1
";
//$res = $db->select("Product", "*", "$where ORDER BY producttech_id, name LIMIT 1");
mfLoghandler::singleton()->debug($sql);
$res = $db->query($sql);
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Product($data);
@@ -107,7 +121,7 @@ class ProductModel {
return null;
}
public static function count($filter) {
public static function count($filter = false) {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);