mirror of
https://github.com/mbirth/tcl_update_db.git
synced 2024-11-13 00:16:46 +00:00
Tables now showing.
This commit is contained in:
parent
1ea640b5f1
commit
1edabd5b74
11
assets/style.css
Executable file
11
assets/style.css
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
table td+td {
|
||||||
|
border-left: 1px dashed green;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.empty {
|
||||||
|
color: silver;
|
||||||
|
}
|
@ -2,6 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>BlackBerry/TCL Firmware List</title>
|
<title>BlackBerry/TCL Firmware List</title>
|
||||||
|
<link rel="stylesheet" href="assets/style.css"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
@ -13,24 +14,37 @@ use \TclUpdates\SQLiteReader;
|
|||||||
$db = new SQLiteReader();
|
$db = new SQLiteReader();
|
||||||
|
|
||||||
$allVars = $db->getAllVariants();
|
$allVars = $db->getAllVariants();
|
||||||
|
$unknowns = $db->getUnknownRefs();
|
||||||
|
if (count($unknowns) > 0) {
|
||||||
|
$variants = array();
|
||||||
|
foreach ($unknowns as $uref) {
|
||||||
|
$variants[$uref] = '';
|
||||||
|
}
|
||||||
|
$allVars['Unknown'] = array(
|
||||||
|
'Variants' => $variants,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($allVars as $family => $models) {
|
foreach ($allVars as $family => $models) {
|
||||||
foreach ($models as $model => $variants) {
|
foreach ($models as $model => $variants) {
|
||||||
echo '<h2>' . $family . ' ' . $model . '</h2>' . PHP_EOL;
|
echo '<h2>' . $family . ' ' . $model . '</h2>' . PHP_EOL;
|
||||||
echo '<table>';
|
$allVersions = $db->getAllVersionsForModel($model);
|
||||||
|
echo '<table><tbody>';
|
||||||
foreach ($variants as $ref => $name) {
|
foreach ($variants as $ref => $name) {
|
||||||
echo '<tr><td>' . $ref . '</td>' . '</tr>' . PHP_EOL;
|
echo '<tr><td>' . $ref . '</td>';
|
||||||
|
$refVersions = $db->getAllVersionsForRef($ref);
|
||||||
|
foreach ($allVersions as $v) {
|
||||||
|
if (in_array($v, $refVersions, true)) {
|
||||||
|
echo '<td>' . $v . '</td>';
|
||||||
|
} else {
|
||||||
|
echo '<td class="empty">------</td>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo '</tr>' . PHP_EOL;
|
||||||
}
|
}
|
||||||
echo '</table>';
|
echo '</tbody></table>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print_r($db->getAllUpdates('PRD-63117-011', $db::BOTH));
|
|
||||||
|
|
||||||
print_r($db->getLatestUpdate('PRD-63117-011', $db::BOTH));
|
|
||||||
|
|
||||||
|
|
||||||
print_r($db->getUnknownPrds());
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -20,7 +20,7 @@ class SQLiteReader
|
|||||||
$this->pdo->exec('PRAGMA foreign_keys=on;');
|
$this->pdo->exec('PRAGMA foreign_keys=on;');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAllPrds()
|
public function getAllRefs()
|
||||||
{
|
{
|
||||||
$sql = 'SELECT DISTINCT curef FROM updates ORDER BY curef;';
|
$sql = 'SELECT DISTINCT curef FROM updates ORDER BY curef;';
|
||||||
$sqlresult = $this->pdo->query($sql);
|
$sqlresult = $this->pdo->query($sql);
|
||||||
@ -31,7 +31,7 @@ class SQLiteReader
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAllKnownPrds()
|
public function getAllKnownRefs()
|
||||||
{
|
{
|
||||||
$sql = 'SELECT DISTINCT ref FROM devices ORDER BY ref;';
|
$sql = 'SELECT DISTINCT ref FROM devices ORDER BY ref;';
|
||||||
$sqlresult = $this->pdo->query($sql);
|
$sqlresult = $this->pdo->query($sql);
|
||||||
@ -42,10 +42,10 @@ class SQLiteReader
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUnknownPrds()
|
public function getUnknownRefs()
|
||||||
{
|
{
|
||||||
$knownPrds = $this->getAllKnownPrds();
|
$knownPrds = $this->getAllKnownRefs();
|
||||||
$allPrds = $this->getAllPrds();
|
$allPrds = $this->getAllRefs();
|
||||||
$unknownPrds = array_diff($allPrds, $knownPrds);
|
$unknownPrds = array_diff($allPrds, $knownPrds);
|
||||||
return $unknownPrds;
|
return $unknownPrds;
|
||||||
}
|
}
|
||||||
@ -99,4 +99,47 @@ class SQLiteReader
|
|||||||
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getAllVersionsForRef($ref = null)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT fv, tv FROM updates u LEFT JOIN files f ON u.file_sha1=f.sha1';
|
||||||
|
$params_arr = array();
|
||||||
|
if (!is_null($ref)) {
|
||||||
|
$sql .= ' WHERE curef=?';
|
||||||
|
$params_arr[] = $ref;
|
||||||
|
}
|
||||||
|
$stmt = $this->pdo->prepare($sql);
|
||||||
|
$ok = $stmt->execute($params_arr);
|
||||||
|
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
|
$version = array();
|
||||||
|
foreach ($result as $row) {
|
||||||
|
if (!is_null($row['fv'])) {
|
||||||
|
$version[] = $row['fv'];
|
||||||
|
}
|
||||||
|
$version[] = $row['tv'];
|
||||||
|
}
|
||||||
|
$version = array_unique($version);
|
||||||
|
sort($version);
|
||||||
|
return $version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAllVersionsForModel($model)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT fv, tv FROM models m LEFT JOIN devices d ON m.modelId=d.modelId LEFT JOIN updates u ON d.ref=u.curef LEFT JOIN files f ON u.file_sha1=f.sha1 WHERE m.name=?';
|
||||||
|
$stmt = $this->pdo->prepare($sql);
|
||||||
|
$ok = $stmt->execute(array($model));
|
||||||
|
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
|
$version = array();
|
||||||
|
foreach ($result as $row) {
|
||||||
|
if (!is_null($row['fv'])) {
|
||||||
|
$version[] = $row['fv'];
|
||||||
|
}
|
||||||
|
if (!is_null($row['tv'])) {
|
||||||
|
$version[] = $row['tv'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$version = array_unique($version);
|
||||||
|
sort($version);
|
||||||
|
return $version;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user