From 6d1bfcead1cdb00a0da99a4cd2df45ade881aba7 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sun, 24 Sep 2017 19:47:00 +0200 Subject: [PATCH] updated state, now contains the value of each pin of a chip (#id_chip and no more #id_pin_merge) --- build/database/repo/state.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/build/database/repo/state.php b/build/database/repo/state.php index 2b1ff71..ae9160d 100755 --- a/build/database/repo/state.php +++ b/build/database/repo/state.php @@ -14,22 +14,21 @@ * * @id_chip UID de la puce * - * @return states Retourne les données sous forme de tableau de la forme (state, chip, pin, value) + * @return states Retourne les données sous forme de tableau de la forme (state, chip, pin, value) * */ public static function getForChip($id_chip){ - $req = DatabaseDriver::getPDO()->prepare("SELECT s.state, pm.id_chip, GROUP_CONCAT(s.value ORDER BY pm.pin ASC) as pin_values - FROM state as s, pin_merge as pm - WHERE s.id_pin_merge = pm.id_pin_merge - AND pm.id_chip = :id_chip - GROUP BY s.state, pm.id_chip"); - $req->execute([ - ':id_chip' => $id_chip - ]); + $chip = Table::get('chip') + ->select('id_chip') + ->whereId($id_chip); + $req = Table::get('state') + ->select('state') + ->select('value') + ->join('id_chip', $chip); - return $req->fetchAll(); + return $req->fetch(); } }