-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataBase.php
52 lines (46 loc) · 1.42 KB
/
DataBase.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
47
48
49
50
51
52
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
class DataBase extends SQLite3
{
function __construct()
{
$this->open('middleware.db');
}
}
$db = new DataBase();
if(!$db){
echo $db->lastErrorMsg();
} else {
//echo "Opened database successfully\n";
}
$sql =<<<EOF
CREATE TABLE IF NOT EXISTS acoes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
empresa TEXT NOT NULL,
quantidade INT NOT NULL,
preco DOUBLE NOT NULL
);
CREATE TABLE IF NOT EXISTS monitorando (
id INTEGER PRIMARY KEY AUTOINCREMENT,
empresa TEXT NOT NULL,
interesse TEXT NOT NULL,
quantidade INT NOT NULL,
preco DOUBLE NOT NULL
);
CREATE TABLE IF NOT EXISTS notificacoes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
texto TEXT NOT NULL
);
EOF;
$ret = $db->exec($sql);
if(!$ret){
echo $db->lastErrorMsg();
} else {
//echo "Table created successfully\n";
}
$db->close();
?>