Added filter and pagination to Product

This commit is contained in:
Frank Schubert
2022-11-24 20:36:09 +01:00
parent fc71a80dc4
commit 54ae6f62b0
119 changed files with 377 additions and 52238 deletions

View File

@@ -34,21 +34,6 @@ class ProductgroupModel {
return $model;
}
public static function getOne($id) {
if(!is_numeric($id) || !$id) {
throw new Exception("Invalid number", 400);
}
$item = [];
$db = FronkDB::singleton();
$res = $db->select("Productgroup", "*", "id=$id LIMIT 1");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Productgroup($data);
}
return $item;
}
public static function getAll() {
$items = [];
@@ -64,7 +49,7 @@ class ProductgroupModel {
}
public static function getFirst() {
public static function getFirst($filter) {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
@@ -81,7 +66,23 @@ class ProductgroupModel {
return null;
}
public static function search($filter) {
public static function count($filter) {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$sql = "SELECT COUNT(*) as cnt FROM `Productgroup`
WHERE $where
";
$res = $db->query($sql);
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
return $data->cnt;
}
return 0;
}
public static function search($filter, $limit = false) {
$items = [];
$db = FronkDB::singleton();