Commit fb8b13f7 authored by Karamel's avatar Karamel

Merge branch '7' of git.framasoft.org:pasteque/pasteque-server into 7

parents 19d969a9 0c705fea
......@@ -50,17 +50,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();
......@@ -75,7 +69,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 = "
......@@ -117,18 +110,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;
......@@ -186,9 +173,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()) {
......
Markdown is supported
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