-
Notifications
You must be signed in to change notification settings - Fork 1
/
Module.php
executable file
·56 lines (46 loc) · 1.12 KB
/
Module.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
53
54
55
56
<?php
class Module {
private $pdo;
private $id;
private $code;
function __construct()
{
try {
$this->pdo = new PDO("mysql:host=localhost;dbname=database", "root", "");
} catch (PDOException $e) {
echo $e->getMessage();
}
}
public function getId()
{
return $this->id;
}
public function setId($id)
{
$this->id = $id;
}
public function getCode()
{
return $this->code;
}
public function setCode($code)
{
$this->code = $code;
}
public static function getAllModals(){
try {
$pdo = new PDO("mysql:host=localhost;dbname=database", "root", "");
} catch (PDOException $e) {
echo $e->getMessage();
}
return $pdo->query("select * from modules")->fetchAll(PDO::FETCH_ASSOC);
}
public function delModule()
{
$this->pdo->query("delete from modules where id_module = '$this->id'");
}
public function addModule()
{
$this->pdo->query("insert into modules (code) values ('$this->code')");
}
}