diff --git a/ricette.php b/ricette.php index 8a6e961..909e54e 100644 --- a/ricette.php +++ b/ricette.php @@ -56,7 +56,8 @@ $app->get('/ricette/:catID', function ($categoryID) use ($app) { $mysqlconnetion = new MysqlClass; //$mysqlconnetion->connetti(); $query = "select * from (select ID as ricetta_id, titolo, autore, valutazione, difficolta, " . - "(select id from immagini where immagini.id_ricette = ricette.id and bCover = 1) as firstImage " . + "(select id from immagini where immagini.id_ricette = ricette.id and bCover = 1) as firstImage, " . + "(select count(id) from immagini where immagini.id_ricette = ricette.id) as countImages " . "from ricette where ricette.ID_CATEGORIA = " . $categoryID . " order by titolo, autore) as TMP"; $retObj = $mysqlconnetion->queryToObject($query); $mysqlconnetion->disconnetti(); @@ -122,7 +123,8 @@ $app->get('/ricette/search/:numItems/:startItem(/:categoryId(/:difficolta/:autor $queryBase = $queryBase . " order by titolo, autore"; $query = "select * from (select ricette.ID as ricetta_id, categorie.name AS categoria_name, titolo, autore, valutazione, difficolta, " . - "(select id from immagini where immagini.id_ricette = ricette.id and bCover = 1) as firstImage" . + "(select id from immagini where immagini.id_ricette = ricette.id and bCover = 1) as firstImage, " . + "(select count(id) from immagini where immagini.id_ricette = ricette.id) as countImages" . $queryBase . " LIMIT " . $numItems * $startItem . " , " . $numItems . ") as TMP"; $retObj2 = $mysqlconnetion->queryToObject($query);