Commit 0c705fea authored by Karamel's avatar Karamel
Browse files

Fix fix

parent 48ce62c7
......@@ -47,17 +47,11 @@ class ProductsService {
static function getTotal($include_hidden = false) {
$pdo = PDOBuilder::getPDO();
$db = DB::get();
$sql = NULL;
if ($include_hidden) {
$sql = "SELECT COUNT(*) AS TOTAL FROM PRODUCTS LEFT JOIN PRODUCTS_CAT ON "
. "PRODUCTS_CAT.PRODUCT = PRODUCTS.ID "
. "WHERE ISCOMPOSITION = " .$db->false();
. "PRODUCTS_CAT.PRODUCT = PRODUCTS.ID ";
} else {
$sql = "SELECT COUNT(*) AS TOTAL FROM PRODUCTS, PRODUCTS_CAT WHERE "
. "PRODUCTS.ID = PRODUCTS_CAT.PRODUCT AND DELETED = "
. $db->false()
. " AND ISCOMPOSITION = " . $db->false();
$sql = "SELECT COUNT(*) AS TOTAL FROM PRODUCTS LEFT JOIN PRODUCTS_CAT ON "
. "PRODUCTS_CAT.PRODUCT = PRODUCTS.ID "
. "WHERE ISCOMPOSITION = " . $db->false();
if (!$include_hidden) {
$sql .= " AND DELETED = " . $db->false();
}
$stmt = $pdo->prepare($sql);
$stmt->execute();
......@@ -72,7 +66,6 @@ class ProductsService {
$sql = "SELECT COUNT(*) AS TOTAL FROM PRODUCTS LEFT JOIN PRODUCTS_CAT ON "
. "PRODUCTS_CAT.PRODUCT = PRODUCTS.ID "
. "WHERE ISCOMPOSITION = " . $db->false();
. "PRODUCTS_CAT.PRODUCT = PRODUCTS.ID ";
} else {
$sql = "SELECT COUNT(*) AS TOTAL FROM PRODUCTS, PRODUCTS_CAT WHERE "
. "PRODUCTS.ID = PRODUCTS_CAT.PRODUCT AND DELETED = "
......@@ -114,18 +107,12 @@ class ProductsService {
$prds = array();
$pdo = PDOBuilder::getPDO();
$db = DB::get();
$sql = NULL;
if ($include_hidden) {
$sql = "SELECT PRODUCTS.*, PRODUCTS_CAT.* FROM PRODUCTS "
. "LEFT JOIN PRODUCTS_CAT ON "
. "PRODUCTS_CAT.PRODUCT = PRODUCTS.ID "
. "WHERE ISCOMPOSITION = " . $db->false();
} else {
$sql = "SELECT PRODUCTS.*, PRODUCTS_CAT.* FROM PRODUCTS "
. "LEFT JOIN PRODUCTS_CAT ON "
. "PRODUCTS_CAT.PRODUCT = PRODUCTS.ID "
. "WHERE DELETED = " . $db->false()
. " AND ISCOMPOSITION = " . $db->false();
$sql = "SELECT PRODUCTS.*, PRODUCTS_CAT.* FROM PRODUCTS "
. "LEFT JOIN PRODUCTS_CAT ON "
. "PRODUCTS_CAT.PRODUCT = PRODUCTS.ID "
. "WHERE ISCOMPOSITION = " . $db->false();
if (!$include_hidden) {
$sql .= " AND DELETED = " . $db->false();
}
$sql .= " ORDER BY CATORDER, NAME";
$sql .= " LIMIT ".$range." OFFSET ".$start;
......@@ -183,9 +170,10 @@ class ProductsService {
static function getByCategory($categoryId) {
$pdo = PDOBuilder::getPDO();
$db = DB::get();
$stmt = $pdo->prepare("SELECT * FROM PRODUCTS, PRODUCTS_CAT WHERE "
. "PRODUCTS.ID = PRODUCTS_CAT.PRODUCT "
. "AND PRODUCTS.CATEGORY = :cat "
$stmt = $pdo->prepare("SELECT * FROM PRODUCTS LEFT JOIN PRODUCTS_CAT ON "
. "PRODUCTS_CAT.PRODUCT = PRODUCTS.ID "
. "WHERE ISCOMPOSITION = " . $db->false()
. " AND PRODUCTS.CATEGORY = :cat "
. "ORDER BY CATORDER, NAME");
$stmt->bindParam(":cat", $categoryId, \PDO::PARAM_STR);
if ($stmt->execute()) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment