$query -> execute();
}
- }
+ public function getNext($product_id, $nature, $currentVersion) {
+
+ $query = $this -> pdo -> prepare('SELECT * FROM versions WHERE product = :product AND nature = :nature ORDER BY value DESC');
+ $query -> bindValue('product', $product_id);
+ $query -> bindValue('nature', $nature);
+ $query -> execute();
+
+ $results = $query -> fetchAll(PDO::FETCH_ASSOC);
+ $nextPatchVersion = null;
+ foreach ($results as $result) {
+ $versionValue = (int) str_replace(".", "", $result['value']);
+ $currentVersionValue = (int) str_replace(".", "", $currentVersion);
+ if($currentVersionValue == $versionValue - 1) {
+ $nextPatchVersion = new Version($result['id'], $result['value'], $result['product'], $result['nature']);
+ }
+ }
+ $query->closeCursor();
+ return $nextPatchVersion;
+ }
+ }
\ No newline at end of file