Repository navigation
Expand file tree
/
Copy pathinstall.php
More file actions
105 lines (85 loc) · 1.97 KB
/
Copy pathinstall.php
File metadata and controls
105 lines (85 loc) · 1.97 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
require __DIR__ . '/database.php';
$c = db_connect_server();
if (!$c) die("DB connection failed");
$DB_NAME = 'basak_sakalli';
//Creating Database
if (!$c->query("CREATE DATABASE IF NOT EXISTS `$DB_NAME` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci")) {
die("DB create error: " . $c->error);
}
//Database selection
if (!$c->select_db($DB_NAME)) {
die("DB select error: " . $c->error);
}
// Creating tables
$schema = "
CREATE TABLE IF NOT EXISTS users (
user_id INT PRIMARY KEY,
username VARCHAR(50),
password VARCHAR(255),
user_image TEXT,
full_name VARCHAR(100),
email VARCHAR(100),
country VARCHAR(50),
joined_on DATE,
bio TEXT
);
CREATE TABLE IF NOT EXISTS channels (
channel_id INT PRIMARY KEY,
owner_id INT,
channel_image TEXT,
name VARCHAR(100),
description TEXT,
created_on DATE,
category VARCHAR(50)
);
CREATE TABLE IF NOT EXISTS videos (
video_id INT PRIMARY KEY,
channel_id INT,
title VARCHAR(255),
description TEXT,
url TEXT,
duration_seconds INT,
uploaded_at DATETIME,
view_count INT,
like_count INT
);
CREATE TABLE IF NOT EXISTS subscriptions (
subscriber_id INT,
channel_id INT,
subscribed_at DATETIME
);
CREATE TABLE IF NOT EXISTS comments (
comment_id INT PRIMARY KEY,
video_id INT,
user_id INT,
parent_comment_id INT NULL,
body TEXT,
posted_at DATETIME
);
";
if (!$c->multi_query($schema)) {
die("Schema error: " . $c->error);
}
do {
if ($res = $c->store_result()) {
$res->free();
}
} while ($c->next_result());
// Loading the seed data
$sql = file_get_contents(__DIR__ . '/seed.sql');
if (!$sql) die("seed.sql missing or empty");
// Executing the seed part
if ($c->multi_query($sql)) {
do {
if ($res = $c->store_result()) {
$res->free();
}
} while ($c->next_result());
} else {
die("Seed error: " . $c->error);
}
$c->close();
header('Location: login.php');
exit;
?>