Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('class/DBConfig.php');
- class Createtable
- {
- //.....................User....................//
- public function createUserTable()
- {
- $dbObj = new DBConfig();
- $conn = $dbObj->dbConnector();
- try {
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $table_create = "CREATE TABLE IF NOT EXISTS " . $dbObj->user_table . "(
- user_id INT AUTO_INCREMENT ,
- full_name VARCHAR(255),
- email VARCHAR(255) UNIQUE,
- phone VARCHAR(255) UNIQUE,
- user_type VARCHAR(255),
- password VARCHAR(255),
- edit_time datetime,
- active_status INT,
- registration_time datetime NOT NULL DEFAULT NOW(),
- PRIMARY KEY(user_id)
- )";
- $conn->exec($table_create);
- echo 'user_table Created Successfully';
- } catch (PDOException $e) {
- echo 'Table Not Creted' . $e->getMessage();
- }
- }
- //.....................User....................//
- //.....................Room....................//
- public function createRoomTable()
- {
- $dbObj = new DBConfig();
- $conn = $dbObj->dbConnector();
- try {
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $table_create = "CREATE TABLE IF NOT EXISTS " . $dbObj->room_table . "(
- room_id INT AUTO_INCREMENT ,
- room_type VARCHAR(255),
- room_number VARCHAR(255) UNIQUE,
- room_name VARCHAR(255),
- room_price INT,
- number_of_occupancy INT,
- room_description TEXT,
- room_booking_status INT,
- update_time datetime,
- create_time datetime NOT NULL DEFAULT NOW(),
- PRIMARY KEY(room_id,room_number)
- )";
- $conn->exec($table_create);
- echo $dbObj->room_table . "Created Successfully";
- } catch (PDOException $e) {
- echo 'Table Not Creted' . $e->getMessage();
- }
- }
- //.....................Room....................//
- //.....................Room Booking ....................//
- public function createBookingTable()
- {
- $dbObj = new DBConfig();
- $conn = $dbObj->dbConnector();
- try {
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $table_create = "CREATE TABLE IF NOT EXISTS " . $dbObj->room_book_table . "(
- booking_id INT AUTO_INCREMENT ,
- room_number VARCHAR(255),
- customer_id INT,
- from_date date,
- to_date date,
- room_booking_status INT, /* Room booking status=1 is Confirmed, Room Bokoking status=2 is Prebook, Room Booking status 0 available */
- adults INT,
- children INT,
- reference VARCHAR(255),
- update_time datetime,
- create_time datetime NOT NULL DEFAULT NOW(),
- PRIMARY KEY(booking_id),
- FOREIGN KEY (room_number) REFERENCES ". $dbObj->room_table."(room_number)
- )";
- $conn->exec($table_create);
- echo $dbObj->room_book_table . "Created Successfully";
- } catch (PDOException $e) {
- echo 'Table Not Creted' . $e->getMessage();
- }
- }
- //.....................Room Booking ....................//
- //.....................Room payment ....................//
- public function createCustomerPaymentTable()
- {
- $dbObj = new DBConfig();
- $conn = $dbObj->dbConnector();
- try {
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $table_create = "CREATE TABLE IF NOT EXISTS " . $dbObj->customer_booking_payment_table . "(
- payment_id INT AUTO_INCREMENT ,
- room_number VARCHAR(255),
- booking_id INT,
- customer_id INT,
- room_price INT,
- paid_amount INT,
- update_time datetime,
- create_time datetime NOT NULL DEFAULT NOW(),
- PRIMARY KEY(payment_id)
- )";
- $conn->exec($table_create);
- echo $dbObj->room_book_table . "Created Successfully";
- } catch (PDOException $e) {
- echo 'Table Not Creted' . $e->getMessage();
- }
- }
- //.....................Employee....................//
- public function createEmployeeTable()
- {
- $dbObj = new DBConfig();
- $conn = $dbObj->dbConnector();
- try {
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $table_create = "CREATE TABLE IF NOT EXISTS " . $dbObj->employee_table . "(
- employee_id INT AUTO_INCREMENT ,
- employee_name VARCHAR(255),
- employee_designation VARCHAR(255),
- employee_email VARCHAR(255) UNIQUE,
- employee_contact_number VARCHAR(255),
- employee_dob date,
- employee_blood_group VARCHAR(15),
- employee_nid VARCHAR(255),
- employee_address TEXT,
- employee_photo_reference VARCHAR(255),
- reference TEXT,
- active_status INT,
- update_time datetime,
- create_time datetime NOT NULL DEFAULT NOW(),
- PRIMARY KEY(employee_id)
- )";
- $conn->exec($table_create);
- echo $dbObj->employee_table . "Created Successfully";
- } catch (PDOException $e) {
- echo 'Table Not Creted' . $e->getMessage();
- }
- }
- //.....................Employee....................//
- //.....................Customer....................//
- public function createCustomerTable()
- {
- $dbObj = new DBConfig();
- $conn = $dbObj->dbConnector();
- try {
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $table_create = "CREATE TABLE IF NOT EXISTS " . $dbObj->customer_table . "(
- customer_id INT AUTO_INCREMENT ,
- customer_name VARCHAR(255),
- customer_gender VARCHAR(255),
- customer_dateofbirth date,
- customer_type VARCHAR(255),
- customer_email VARCHAR(255),
- customer_contact_number VARCHAR(255) UNIQUE,
- customer_nid VARCHAR(255),
- customer_passport VARCHAR(255),
- customer_driving VARCHAR(255),
- customer_address VARCHAR(255),
- update_time datetime,
- create_time datetime NOT NULL DEFAULT NOW(),
- PRIMARY KEY(customer_id)
- )";
- $conn->exec($table_create);
- echo $dbObj->customer_table . "Created Successfully";
- } catch (PDOException $e) {
- echo 'Table Not Creted' . $e->getMessage();
- }
- }
- //.....................Customer....................//
- //.....................Property....................//
- public function createPropertyTable()
- {
- $dbObj = new DBConfig();
- $conn = $dbObj->dbConnector();
- try {
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $table_create = "CREATE TABLE IF NOT EXISTS " . $dbObj->property_table . "(
- property_id INT AUTO_INCREMENT ,
- property_name VARCHAR(255),
- property_qnt INT,
- property_description VARCHAR(255),
- property_type VARCHAR(255),
- property_destination VARCHAR(255),
- single_property_value INT,
- property_value INT,
- property_date_of_purchase DATE,
- reference VARCHAR(255),
- supplier_id INT,
- update_time datetime,
- create_time datetime NOT NULL DEFAULT NOW(),
- PRIMARY KEY(property_id)
- )";
- $conn->exec($table_create);
- echo $dbObj->property_table . "Created Successfully";
- } catch (PDOException $e) {
- echo 'Table Not Creted' . $e->getMessage();
- }
- }
- //.....................Property....................//
- public function createSupplierTable()
- {
- $dbObj = new DBConfig();
- $conn = $dbObj->dbConnector();
- try {
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $table_create = "CREATE TABLE IF NOT EXISTS " . $dbObj->supplier_table . "(
- supplier_id INT AUTO_INCREMENT ,
- supplier_name VARCHAR(255),
- contact_person VARCHAR(255),
- supplier_contact_number INT,
- supplier_email VARCHAR(255),
- supplier_address VARCHAR(255),
- reference VARCHAR(255),
- update_time datetime,
- create_time datetime NOT NULL DEFAULT NOW(),
- PRIMARY KEY(supplier_id)
- )";
- $conn->exec($table_create);
- echo $dbObj->supplier_table . "Created Successfully";
- } catch (PDOException $e) {
- echo 'Table Not Creted' . $e->getMessage();
- }
- }
- public function createPropertyTypeTable()
- {
- $dbObj = new DBConfig();
- $conn = $dbObj->dbConnector();
- try {
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $table_create = "CREATE TABLE IF NOT EXISTS " . $dbObj->property_type_table . "(
- property_type_id INT AUTO_INCREMENT ,
- property_name VARCHAR(255) UNIQUE,
- reference VARCHAR(255),
- update_time datetime,
- create_time datetime NOT NULL DEFAULT NOW(),
- PRIMARY KEY(property_type_id)
- )";
- $conn->exec($table_create);
- echo $dbObj->property_type_table . "Created Successfully";
- } catch (PDOException $e) {
- echo 'Table Not Creted' . $e->getMessage();
- }
- }
- //.....................Property....................//
- ////.....................Property....................//
- public function createDesignationTable()
- {
- $dbObj = new DBConfig();
- $conn = $dbObj->dbConnector();
- try {
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $table_create = "CREATE TABLE IF NOT EXISTS " . $dbObj->designation_table . "(
- designation_id INT AUTO_INCREMENT ,
- designation VARCHAR(255),
- reference VARCHAR(255),
- update_time datetime,
- create_time datetime NOT NULL DEFAULT NOW(),
- PRIMARY KEY(designation_id)
- )";
- $conn->exec($table_create);
- echo $dbObj->designation_table . "Created Successfully";
- } catch (PDOException $e) {
- echo 'Table Not Creted' . $e->getMessage();
- }
- }
- //.....................Property....................//
- //.....................Property....................//
- public function createFoodTable()
- {
- $dbObj = new DBConfig();
- $conn = $dbObj->dbConnector();
- try {
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $table_create = "CREATE TABLE IF NOT EXISTS " . $dbObj->food_table . "(
- food_id INT AUTO_INCREMENT ,
- food_name VARCHAR(255),
- food_price INT,
- food_item_for VARCHAR(255),
- food_description TEXT,
- reference VARCHAR(255),
- update_time datetime,
- create_time datetime NOT NULL DEFAULT NOW(),
- PRIMARY KEY(food_id)
- )";
- $conn->exec($table_create);
- echo $dbObj->food_table . "Created Successfully";
- } catch (PDOException $e) {
- echo 'Table Not Creted' . $e->getMessage();
- }
- }
- //.....................Property....................//
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement