-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel_adm.php
More file actions
53 lines (44 loc) · 1.19 KB
/
Copy pathmodel_adm.php
File metadata and controls
53 lines (44 loc) · 1.19 KB
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
<?php
session_start();
class Model
{
private $server = "localhost";
private $username = "root";
private $password = "";
private $db = "deutsch_school";
private $conn;
public function __construct()
{
try {
$this->conn = new mysqli($this->server, $this->username, $this->password, $this->db);
} catch (\Throwable $th) {
echo "Connection error " . $th->getMessage();
}
}
public function fetch()
{
$data = [];
$query = "SELECT * FROM etudiants";
$sql = $this->conn->query($query);
if ($sql) {
while ($row = $sql->fetch_assoc()) {
$data[] = $row;
}
}
return $data;
}
public function date_range($start_date, $end_date)
{
$data = [];
if (isset($start_date) && isset($end_date)) {
$query = "SELECT * FROM etudiants WHERE `Date` BETWEEN '$start_date' AND '$end_date'";
$sql = $this->conn->query($query);
if ($sql) {
while ($row = $sql->fetch_assoc()) {
$data[] = $row;
}
}
}
return $data;
}
}