generated from teknasyon-bootcamp/homework5
-
Notifications
You must be signed in to change notification settings - Fork 4
/
section-delete.php
59 lines (50 loc) · 1.44 KB
/
section-delete.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
57
58
59
<?php
require "vendor/autoload.php";
$config = require "config.php";
$config = require "config.php";
$engine = $config['engine'];
$host = $config['host'];
$user = $config['user'];
$pass = $config['password'];
$log_type = $config['logging'];
$log_file_dir = __DIR__."/storage/logs/logs.log";
use App\DB\Engine\Mysql;
use App\DB\Engine\MongoDB;
use App\Db\Database;
use App\Logger\Driver\Database as LoggerDatabase;
use App\Logger\Driver\File;
use App\Logger\Logger;
use App\Logger\LoggableInterface;
if ($engine == "mysql") {
$driver = new Mysql($host, $user, $pass, "book_app");
} elseif ($engine =="mongodb") {
$driver = new MongoDB("", "", "", "", "", []);
}
if($log_type =="file"){
$logger = new Logger(new File($log_file_dir));
}else{
$logger = new Logger(new LoggerDatabase($driver));
}
try{
$db = new Database();
$db->setDriver($driver);
}catch (Exception $e){
$logger->log($e, LoggableInterface::ERROR);
}
$id = $_GET['id'];
try {
$is_deleted = $db->delete("section",$id);
}catch (Exception $e){
$logger->log($e, LoggableInterface::ERROR);
}
?>
<?php include "_shared/header.php";?>
<?php
if($is_deleted){
echo "<p class='text-center alert-success'>Bölüm başarıyla silindi</p>";
echo "<br>";
echo "<div class='d-flex justify-content-center'><a href='http://localhost/homework5-hw5_grup3/index.php' class='btn btn-primary mt-5'>Anasayfaya geri dön</a></div>";
}
?>
?>
<?php include "_shared/footer.php";?>