-
Notifications
You must be signed in to change notification settings - Fork 1
/
create_table.php
48 lines (41 loc) · 1.25 KB
/
create_table.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
<?php
require_once('Connection.php');
$connection = new Connection();
// Create connection
$conn = new mysqli($connection->servername, $connection->username, $connection->password, $connection->dbname);
// Check connection
// sql to create table
$sql = "CREATE TABLE restaurants (
id VARCHAR(255) NOT NULL,
firstname VARCHAR(30) NOT NULL,
email VARCHAR(50),
phone VARCHAR(50),
is_verified VARCHAR(5),
is_active VARCHAR(50),
user_address VARCHAR(250),
token VARCHAR(200),
user_password VARCHAR(50),
reg_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)";
//if ($connection->connectToLocalDb()->query($sql) === TRUE) {
// echo "Table created successfully";
//} else {
// echo "Error creating table: " . $conn->error;
//}
$createFoodItemSQL = "CREATE TABLE food_items (
id VARCHAR(50) NOT NULL,
name VARCHAR(50) NOT NULL,
description VARCHAR(50),
price VARCHAR(50),
restaurant_token VARCHAR(50),
is_available VARCHAR(5),
image_url VARCHAR(50),
date_uploaded TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)";
if ($connection->connectToDb()->query($createFoodItemSQL) === TRUE) {
echo "Food Item created successfully";
} else {
echo "Error creating food table: " . $conn->error;
}
$connection->connectToDb()->close();
?>