updated state, now contains the value of each pin of a chip (#id_chip and no more #id_pin_merge)

This commit is contained in:
xdrm-brackets 2017-09-24 19:47:00 +02:00
parent 0945b7da1b
commit 6d1bfcead1
1 changed files with 9 additions and 10 deletions

View File

@ -14,22 +14,21 @@
* *
* @id_chip<int> UID de la puce * @id_chip<int> UID de la puce
* *
* @return states<Array> Retourne les données sous forme de tableau de la forme (state, chip, pin, value) * @return states<Array> Retourne les données sous forme de tableau de la forme (state, chip, pin, value)
* *
*/ */
public static function getForChip($id_chip){ 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 $chip = Table::get('chip')
FROM state as s, pin_merge as pm ->select('id_chip')
WHERE s.id_pin_merge = pm.id_pin_merge ->whereId($id_chip);
AND pm.id_chip = :id_chip
GROUP BY s.state, pm.id_chip");
$req->execute([
':id_chip' => $id_chip
]);
$req = Table::get('state')
->select('state')
->select('value')
->join('id_chip', $chip);
return $req->fetchAll(); return $req->fetch();
} }
} }