}
- public function findLastVersion() {
+ public function findLastVersionForId($id) {
- $query = $this -> pdo -> prepare('SELECT versions FROM changelogs');
+ $query = $this -> pdo -> prepare('SELECT versions FROM changelogs WHERE id = :id');
+ $query -> bindValue('id', $id);
$query -> execute();
// GETTING LAST DECLARED VERSION ID
$lastVersionId = null;
- $results = $query -> fetchAll(PDO::FETCH_ASSOC);
- foreach ($results as $result) {
- $versionArray = explode(';',$result['versions']);
+ $result = $query -> fetch(PDO::FETCH_ASSOC);
+ $versions = explode("|", $result['versions']);
+ foreach ($versions as $version) {
+ $versionArray = explode(';', $version);
$versionId = $versionArray[0];
$versionDeclaration = $versionArray[1];
- if(!isset($lastVersionDeclaration) || $versionDeclaration > $lastVersionDeclaration) {
+ if(!isset($lastVersionDeclaration) || $versionDeclaration >= $lastVersionDeclaration) {
$lastVersionDeclaration = $versionDeclaration;
$lastVersionId = $versionId;
}
return $version;
}
- public function findLastVersionDeclaration() {
+ public function findLastVersionDeclarationForId($id) {
- $query = $this -> pdo -> prepare('SELECT versions FROM changelogs');
+ $query = $this -> pdo -> prepare('SELECT versions FROM changelogs WHERE id = :id');
+ $query -> bindValue('id', $id);
$query -> execute();
// GETTING LAST VERSION DECLARATION
$lastVersionDeclaration = null;
- $results = $query -> fetchAll(PDO::FETCH_ASSOC);
- foreach ($results as $result) {
- $versionArray = explode(';',$result['versions']);
+ $result = $query -> fetch(PDO::FETCH_ASSOC);
+ $versions = explode("|", $result['versions']);
+ foreach ($versions as $version) {
+ $versionArray = explode(';',$version);
$versionDeclaration = $versionArray[1];
- if(!isset($lastVersionDeclaration) || $versionDeclaration > $lastVersionDeclaration) {
+ if(!isset($lastVersionDeclaration) || $versionDeclaration >= $lastVersionDeclaration) {
$lastVersionDeclaration = $versionDeclaration;
}
}