PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
-- Create the Events table CREATE TABLE Events ( id INT AUTO_INCREMENT PRIMARY KEY, Author INT NOT NULL, Title VARCHAR(255) NOT NULL, Description TEXT NOT NULL, Start DATETIME NOT NULL, End DATETIME NOT NULL, URL VARCHAR(255) NOT NULL, Location VARCHAR(255) NOT NULL, Location_URL VARCHAR(255) NOT NULL, `Virtual` TINYINT NOT NULL, Multiple_dates TINYINT DEFAULT 0, Recurring TINYINT DEFAULT 0, On_Demand TINYINT DEFAULT 0 ) ENGINE=InnoDB; -- Create the Events_Vendors table CREATE TABLE Events_Vendors ( vid INT AUTO_INCREMENT PRIMARY KEY, Vendor VARCHAR(255) NOT NULL ) ENGINE=InnoDB; -- Create the Events_Vendors_Tags table CREATE TABLE Events_Vendors_Tags ( event_id INT NOT NULL, vendor_id INT NOT NULL, PRIMARY KEY (event_id, vendor_id), FOREIGN KEY (event_id) REFERENCES Events(id) ON DELETE CASCADE, FOREIGN KEY (vendor_id) REFERENCES Events_Vendors(vid) ON DELETE CASCADE ) ENGINE=InnoDB; -- Create the Events_Countries table CREATE TABLE Events_Countries ( cid INT AUTO_INCREMENT PRIMARY KEY, Country VARCHAR(255) NOT NULL ) ENGINE=InnoDB; -- Create the Events_Countries_Tags table CREATE TABLE Events_Countries_Tags ( event_id INT NOT NULL, country_id INT NOT NULL, PRIMARY KEY (event_id, country_id), FOREIGN KEY (event_id) REFERENCES Events(id) ON DELETE CASCADE, FOREIGN KEY (country_id) REFERENCES Events_Countries(cid) ON DELETE CASCADE ) ENGINE=InnoDB; -- Insert sample events INSERT INTO Events (Author, Title, Description, Start, End, URL, Location, Location_URL, `Virtual`, Multiple_dates, Recurring, On_Demand) VALUES (1, 'Event 1', 'Description for Event 1', '2024-01-01 10:00:00', '2024-01-01 12:00:00', 'https://event1.com', 'Location 1', 'https://location1.com', 1, 0, 0, 0), (2, 'Event 2', 'Description for Event 2', '2024-02-01 10:00:00', '2024-02-01 12:00:00', 'https://event2.com', 'Location 2', 'https://location2.com', 0, 0, 0, 0); -- Insert sample vendors INSERT INTO Events_Vendors (Vendor) VALUES ('Avaya'), ('Cisco'), ('Extreme'); -- Insert sample vendor-event relationships INSERT INTO Events_Vendors_Tags (event_id, vendor_id) VALUES (1, 1), (1, 2), (2, 3); -- Insert sample countries INSERT INTO Events_Countries (Country) VALUES ('Singapore'), ('UK'), ('Germany'); -- Insert sample country-event relationships INSERT INTO Events_Countries_Tags (event_id, country_id) VALUES (1, 1), (1, 2), (2, 3);
Copy Clear
Copy Format Clear
<?php use Carbon\Carbon; $input = json_decode(file_get_contents('php://input'), true); printf(json_encode($input)); $currentVendors = []; $result = $mysqli->query("SELECT * FROM Events"); while ($row = $result->fetch_assoc()) { $currentVendors[] = $row; } printf(json_encode($currentVendors)) ?>
Show:  
Copy Clear