pdo->prepare("INSERT INTO UE(code, label, required, volumeCours, volumeTD, volumeTP, disabled, Formation_idFormation) VALUE(:code, :label, :required, :volCours, :volTD, :volTP, :disabled, :idFormation) "); $st->execute([ "code" => $code, "label" => $label, "required" => $required ? 1 : 0, "volCours" => $volumeCours, "volTD" => $volumeTD, "volTP" => $volumeTP, "disabled" => $disabled ? 1 : 0, "idFormation" => $defaultFormation ]); return $this->pdo->lastInsertId(); } public function update(string $code, array $data) : bool{ $updSt = ""; foreach ($data as $key => $field){ $updSt .= "$key = :$key,"; } $updSt = rtrim($updSt,","); $st = $this->pdo->prepare("UPDATE UE SET $updSt WHERE code = :code"); return $st->execute(array_merge($data,[ "code" => $code ])); } public function delete(string $code) : bool { $st = $this->pdo->prepare("DELETE FROM UE WHERE code = :code"); return $st->execute([ "code" => $code ]); } public function disable(string $code) : bool { return $this->update($code, ["disabled" => 1]); } public function enable(string $code) : bool { return $this->update($code, ["disabled" => 0]); } }