1
0
mirror of https://github.com/mbirth/tcl_update_db.git synced 2024-12-27 04:54:08 +00:00

Show versions without OTA in different style.

This commit is contained in:
Markus Birth 2017-12-17 19:33:33 +01:00
parent c8dd58aab1
commit 3de1b94816
Signed by: mbirth
GPG Key ID: A9928D7A098C3A9A
3 changed files with 21 additions and 3 deletions

View File

@ -22,3 +22,7 @@ td.empty {
tr:hover { tr:hover {
background-color: #ddd; background-color: #ddd;
} }
td.fullonly {
color: #88f;
}

View File

@ -33,9 +33,14 @@ foreach ($allVars as $family => $models) {
foreach ($variants as $ref => $name) { foreach ($variants as $ref => $name) {
echo '<tr><td class="ref">' . $ref . '</td>'; echo '<tr><td class="ref">' . $ref . '</td>';
$refVersions = $db->getAllVersionsForRef($ref); $refVersions = $db->getAllVersionsForRef($ref);
$allOta = $db->getAllVersionsForRef($ref, $db::OTA_ONLY);
foreach ($allVersions as $v) { foreach ($allVersions as $v) {
if (in_array($v, $refVersions, true)) { if (in_array($v, $refVersions, true)) {
if (in_array($v, $allOta)) {
echo '<td>' . $v . '</td>'; echo '<td>' . $v . '</td>';
} else {
echo '<td class="fullonly">' . $v . '</td>';
}
} else { } else {
echo '<td class="empty">- - -</td>'; echo '<td class="empty">- - -</td>';
} }

View File

@ -117,14 +117,23 @@ class SQLiteReader
return $result; return $result;
} }
public function getAllVersionsForRef($ref = null) public function getAllVersionsForRef($ref = null, $which = self::BOTH)
{ {
$sql = 'SELECT fv, tv FROM updates u LEFT JOIN files f ON u.file_sha1=f.sha1'; $sql = 'SELECT fv, tv FROM updates u LEFT JOIN files f ON u.file_sha1=f.sha1';
$where_arr = array();
$params_arr = array(); $params_arr = array();
if (!is_null($ref)) { if (!is_null($ref)) {
$sql .= ' WHERE curef=?'; $where_arr[] = 'curef=?';
$params_arr[] = $ref; $params_arr[] = $ref;
} }
if ($which == self::OTA_ONLY) {
$where_arr[] = 'fv IS NOT null';
} elseif ($which == self::FULL_ONLY) {
$where_arr[] = 'fv IS null';
}
if (count($where_arr) > 0) {
$sql .= ' WHERE ' . implode(' AND ', $where_arr);
}
$stmt = $this->pdo->prepare($sql); $stmt = $this->pdo->prepare($sql);
$ok = $stmt->execute($params_arr); $ok = $stmt->execute($params_arr);
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC); $result = $stmt->fetchAll(\PDO::FETCH_ASSOC);