-
Notifications
You must be signed in to change notification settings - Fork 0
/
CreateTable.php
46 lines (43 loc) · 1.08 KB
/
CreateTable.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
class MyDB extends SQLite3
{
function __construct()
{
$this->open('./db/factory_log.db');
}
}
$db = new MyDB();
if(!$db){
echo $db->lastErrorMsg();
} else {
echo "Opened database successfully\n";
}
$sql =<<<EOF
CREATE TABLE log
(
ID INTEGER PRIMARY KEY AUTOINCREMENT,
TRACKING TEXT NOT NULL,
BTMAC TEXT NOT NULL,
WiFiMAC TEXT NOT NULL,
HM10 TEXT NOT NULL,
WiFi TEXT NOT NULL,
MIC TEXT NOT NULL,
DHT11 TEXT NOT NULL,
GPIO TEXT NOT NULL,
APA102C TEXT NOT NULL,
SPK TEXT NOT NULL,
NOTE TEXT,
inspection_time INTEGER NOT NULL,
date_add DATETIME NOT NULL
);
EOF;
$ret = $db->exec($sql);
if(!$ret){
echo $db->lastErrorMsg();
} else {
echo "Table created successfully\n";
}
$db->close();
$results = shell_exec('sudo chmod 777 ./db/factory_log.db');
echo $results;
?>