forked from khslsahan/backery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnection.php
188 lines (122 loc) · 5.17 KB
/
connection.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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?php
$servername="localhost";
$username="root";
$password="";
$conn=mysqli_connect($servername,$username,$password);
if(!$conn)
die('Cannot connect'.mysqli_error($conn));
$query="CREATE DATABASE IF NOT EXISTS creativebakery";
$db=mysqli_query($conn,$query) or die ('cannot create database'.mysqli_connect_error());
mysqli_select_db($conn,"creativebakery");
// =========================
// category table
// =======================
$query="CREATE TABLE IF NOT EXISTS `category` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`category_name` varchar(255) NOT NULL,
`category_description` varchar(535) NOT NULL,
`creation_date` timestamp NOT NULL DEFAULT current_timestamp(),
`update_date` timestamp NULL DEFAULT NULL,
PRIMARY KEY(`id`)
)";
$tblcategory=mysqli_query($conn,$query) or die ('cannot create table category'.mysqli_error($conn));
// =========================
// Order table
// =======================
$query="CREATE TABLE IF NOT EXISTS `orders` (
`order_id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`quantity` int(11) NOT NULL,
`order_date` timestamp NOT NULL DEFAULT current_timestamp(),
`paymet_method` varchar(255) NOT NULL,
`delivery_time` timestamp NULL DEFAULT NULL,
PRIMARY KEY(`order_id`)
)";
$tbloder=mysqli_query($conn,$query) or die ('cannot create table orders'.mysqli_error($conn));
// =========================
// ordersTrack TABLE
// =======================
$query="CREATE TABLE IF NOT EXISTS `order_track_history` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`order_id` int(11) NOT NULL,
`status` varchar(255) NOT NULL,
`remark` varchar(255) NOT NULL,
`post_date` timestamp NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY(`id`)
)";
$tbloderTrack=mysqli_query($conn,$query) or die ('cannot create table ordersTrack'.mysqli_error($conn));
// =========================
// products TABLE
// =======================
$query="CREATE TABLE IF NOT EXISTS `products` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`category_id` int(11) NOT NULL,
`product_name` varchar(255) NOT NULL,
`product_price` float NOT NULL,
`product_quantity` int(11) NOT NULL,
`product_description` varchar(535) NOT NULL,
`product_image` longtext NOT NULL,
`product_availability` tinyint(1) NOT NULL,
`discount` float DEFAULT NULL,
`post_date` timestamp NOT NULL DEFAULT current_timestamp(),
`update_date` timestamp NULL DEFAULT NULL,
PRIMARY KEY(`id`)
)";
$tblproducts=mysqli_query($conn,$query) or die ('cannot create table products'.mysqli_error($conn));
// =========================
// products review
// =======================
$query="CREATE TABLE IF NOT EXISTS `product_review` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`product_id` int(11) NOT NULL,
`ratings` int(11) NOT NULL,
`user_name` varchar(255) NOT NULL,
`summary` varchar(255) NOT NULL,
`review` varchar(535) NOT NULL,
`review_date` timestamp NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY(`id`)
)";
$tblproductreviews=mysqli_query($conn,$query) or die ('cannot create table product reviews'.mysqli_error($conn));
// =========================
// user table
// =======================
$query="CREATE TABLE IF NOT EXISTS `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`first_name` varchar(255) NOT NULL,
`last_name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`contact_no` varchar(255) NOT NULL,
`password` char(128) NOT NULL,
`role` varchar(255) NOT NULL,
`address` varchar(535) DEFAULT NULL,
`register_date` timestamp NOT NULL DEFAULT current_timestamp(),
`updated_date` timestamp NULL DEFAULT NULL,
PRIMARY KEY(`id`)
)";
$tbluser=mysqli_query($conn,$query) or die ('cannot create table user'.mysqli_error($conn));
// =========================
// user log
// =======================
$query="CREATE TABLE IF NOT EXISTS `user_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_email` varchar(255) NOT NULL,
`user_ip` varchar(535) NOT NULL,
`login_time` timestamp NOT NULL DEFAULT current_timestamp(),
`logout_time` timestamp NULL DEFAULT NULL,
`status` tinyint(1) NOT NULL,
PRIMARY KEY(`id`)
)";
$tbluserlog=mysqli_query($conn,$query) or die ('cannot create table userlog'.mysqli_error($conn));
// =========================
// Wishlist
// =======================
$query="CREATE TABLE IF NOT EXISTS `wishlist` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`posting_date` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY(`id`)
)";
$tbluserlog=mysqli_query($conn,$query) or die ('cannot create table userlog'.mysqli_error($conn));
?>