Changeset 2651
- Timestamp:
- 5/23/2012 5:39:15 AM (12 months ago)
- File:
-
- 1 edited
-
trunk/website/scripts/UpdateList.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/website/scripts/UpdateList.php
r2650 r2651 93 93 //Prepare the list of updates 94 94 $pdo = new Database(); 95 96 /* This following function uses the following function for version comparisons: 97 98 CREATE FUNCTION GetVerMajorMinor(s VARCHAR(255)) 99 RETURNS DECIMAL(6,3) DETERMINISTIC 100 RETURN CAST( 101 SUBSTRING_INDEX(s, '.', 2) 102 AS DECIMAL(6,3) 103 ); 104 105 CREATE FUNCTION GetVerReleaseBuild(s VARCHAR(255)) 106 RETURNS DECIMAL(6,3) DETERMINISTIC 107 RETURN CAST( 108 CASE 109 WHEN LOCATE('.', s) = 0 THEN NULL 110 WHEN LOCATE('.', s, LOCATE('.', s)+1) = 0 THEN SUBSTRING_INDEX(s, '.', -1) 111 ELSE SUBSTRING_INDEX(s, '.', -2) 112 END 113 AS DECIMAL(6,3) 114 ); 115 116 */ 117 95 118 $statement = $pdo->prepare('SELECT DownloadID 96 119 FROM downloads … … 100 123 ( 101 124 (MinVersion IS NULL AND MaxVersion IS NULL) OR 102 (MinVersion IS NULL AND MaxVersion > :Version) OR 103 (MinVersion <= :Version AND MaxVersion IS NULL) OR 125 (MinVersion IS NULL AND -- Version < MaxVersion 126 ( 127 GetVerMajorMinor(MaxVersion) > :VersionMajorMinor OR -- a.b > a.b 128 (GetVerMajorMinor(MaxVersion) = :VersionMajorMinor AND -- a.b = a.b; c.d > c.d 129 GetVerReleaseBuild(MaxVersion) > :VersionReleaseBuild) 130 ) 131 ) OR 132 ( -- Version >= MinVersion 133 ( 134 GetVerMajorMinor(MinVersion) < :VersionMajorMinor OR -- a.b < a.b 135 (GetVerMajorMinor(MinVersion) = :VersionMajorMinor AND -- a.b = a.b; c.d <= c.d 136 GetVerReleaseBuild(MinVersion) <= :VersionReleaseBuild) 137 ) AND 138 MaxVersion IS NULL 139 ) OR 104 140 (MinVersion <= :Version AND MaxVersion > :Version) 105 141 ) 106 142 ORDER BY `Type` ASC'); 143 144 $clientComponents = explode('.', $clientVersion); 145 $versionMajorMinor = floatval(implode('.', array_splice($clientComponents, 0, 2))); 146 $versionReleaseBuild = floatval(implode('.', $clientComponents)); 107 147 $statement->bindParam('Version', $clientVersion); 148 $statement->bindParam('VersionMajorMinor', $versionMajorMinor); 149 $statement->bindParam('VersionReleaseBuild', $versionReleaseBuild); 108 150 $statement->execute(); 109 151
Note: See TracChangeset
for help on using the changeset viewer.
