Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.22 KB | None | 0 0
  1. <?php
  2. require_once('class/DBConfig.php');
  3. class Createtable
  4. {
  5.  
  6. //.....................User....................//
  7.  
  8. public function createUserTable()
  9. {
  10. $dbObj = new DBConfig();
  11. $conn = $dbObj->dbConnector();
  12. try {
  13. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  14. $table_create = "CREATE TABLE IF NOT EXISTS " . $dbObj->user_table . "(
  15. user_id INT AUTO_INCREMENT ,
  16. full_name VARCHAR(255),
  17. email VARCHAR(255) UNIQUE,
  18. phone VARCHAR(255) UNIQUE,
  19. user_type VARCHAR(255),
  20. password VARCHAR(255),
  21. edit_time datetime,
  22. active_status INT,
  23. registration_time datetime NOT NULL DEFAULT NOW(),
  24. PRIMARY KEY(user_id)
  25. )";
  26. $conn->exec($table_create);
  27. echo 'user_table Created Successfully';
  28. } catch (PDOException $e) {
  29. echo 'Table Not Creted' . $e->getMessage();
  30. }
  31.  
  32. }
  33.  
  34. //.....................User....................//
  35.  
  36.  
  37. //.....................Room....................//
  38.  
  39. public function createRoomTable()
  40. {
  41. $dbObj = new DBConfig();
  42. $conn = $dbObj->dbConnector();
  43. try {
  44. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  45. $table_create = "CREATE TABLE IF NOT EXISTS " . $dbObj->room_table . "(
  46. room_id INT AUTO_INCREMENT ,
  47. room_type VARCHAR(255),
  48. room_number VARCHAR(255) UNIQUE,
  49. room_name VARCHAR(255),
  50. room_price INT,
  51. number_of_occupancy INT,
  52. room_description TEXT,
  53. room_booking_status INT,
  54. update_time datetime,
  55. create_time datetime NOT NULL DEFAULT NOW(),
  56. PRIMARY KEY(room_id,room_number)
  57. )";
  58. $conn->exec($table_create);
  59. echo $dbObj->room_table . "Created Successfully";
  60. } catch (PDOException $e) {
  61. echo 'Table Not Creted' . $e->getMessage();
  62. }
  63. }
  64.  
  65. //.....................Room....................//
  66.  
  67. //.....................Room Booking ....................//
  68.  
  69. public function createBookingTable()
  70. {
  71. $dbObj = new DBConfig();
  72. $conn = $dbObj->dbConnector();
  73. try {
  74. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  75. $table_create = "CREATE TABLE IF NOT EXISTS " . $dbObj->room_book_table . "(
  76. booking_id INT AUTO_INCREMENT ,
  77. room_number VARCHAR(255),
  78. customer_id INT,
  79. from_date date,
  80. to_date date,
  81. room_booking_status INT, /* Room booking status=1 is Confirmed, Room Bokoking status=2 is Prebook, Room Booking status 0 available */
  82. adults INT,
  83. children INT,
  84. reference VARCHAR(255),
  85. update_time datetime,
  86. create_time datetime NOT NULL DEFAULT NOW(),
  87. PRIMARY KEY(booking_id),
  88. FOREIGN KEY (room_number) REFERENCES ". $dbObj->room_table."(room_number)
  89. )";
  90. $conn->exec($table_create);
  91. echo $dbObj->room_book_table . "Created Successfully";
  92. } catch (PDOException $e) {
  93. echo 'Table Not Creted' . $e->getMessage();
  94. }
  95. }
  96.  
  97. //.....................Room Booking ....................//
  98. //.....................Room payment ....................//
  99.  
  100. public function createCustomerPaymentTable()
  101. {
  102. $dbObj = new DBConfig();
  103. $conn = $dbObj->dbConnector();
  104. try {
  105. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  106. $table_create = "CREATE TABLE IF NOT EXISTS " . $dbObj->customer_booking_payment_table . "(
  107. payment_id INT AUTO_INCREMENT ,
  108. room_number VARCHAR(255),
  109. booking_id INT,
  110. customer_id INT,
  111. room_price INT,
  112. paid_amount INT,
  113. update_time datetime,
  114. create_time datetime NOT NULL DEFAULT NOW(),
  115. PRIMARY KEY(payment_id)
  116. )";
  117. $conn->exec($table_create);
  118. echo $dbObj->room_book_table . "Created Successfully";
  119. } catch (PDOException $e) {
  120. echo 'Table Not Creted' . $e->getMessage();
  121. }
  122. }
  123.  
  124. //.....................Employee....................//
  125.  
  126. public function createEmployeeTable()
  127. {
  128. $dbObj = new DBConfig();
  129. $conn = $dbObj->dbConnector();
  130. try {
  131. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  132. $table_create = "CREATE TABLE IF NOT EXISTS " . $dbObj->employee_table . "(
  133. employee_id INT AUTO_INCREMENT ,
  134. employee_name VARCHAR(255),
  135. employee_designation VARCHAR(255),
  136. employee_email VARCHAR(255) UNIQUE,
  137. employee_contact_number VARCHAR(255),
  138. employee_dob date,
  139. employee_blood_group VARCHAR(15),
  140. employee_nid VARCHAR(255),
  141. employee_address TEXT,
  142. employee_photo_reference VARCHAR(255),
  143. reference TEXT,
  144. active_status INT,
  145. update_time datetime,
  146. create_time datetime NOT NULL DEFAULT NOW(),
  147. PRIMARY KEY(employee_id)
  148. )";
  149. $conn->exec($table_create);
  150. echo $dbObj->employee_table . "Created Successfully";
  151. } catch (PDOException $e) {
  152. echo 'Table Not Creted' . $e->getMessage();
  153. }
  154. }
  155. //.....................Employee....................//
  156.  
  157.  
  158. //.....................Customer....................//
  159.  
  160. public function createCustomerTable()
  161. {
  162. $dbObj = new DBConfig();
  163. $conn = $dbObj->dbConnector();
  164. try {
  165. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  166. $table_create = "CREATE TABLE IF NOT EXISTS " . $dbObj->customer_table . "(
  167. customer_id INT AUTO_INCREMENT ,
  168. customer_name VARCHAR(255),
  169. customer_gender VARCHAR(255),
  170. customer_dateofbirth date,
  171. customer_type VARCHAR(255),
  172. customer_email VARCHAR(255),
  173. customer_contact_number VARCHAR(255) UNIQUE,
  174. customer_nid VARCHAR(255),
  175. customer_passport VARCHAR(255),
  176. customer_driving VARCHAR(255),
  177. customer_address VARCHAR(255),
  178. update_time datetime,
  179. create_time datetime NOT NULL DEFAULT NOW(),
  180. PRIMARY KEY(customer_id)
  181. )";
  182. $conn->exec($table_create);
  183. echo $dbObj->customer_table . "Created Successfully";
  184. } catch (PDOException $e) {
  185. echo 'Table Not Creted' . $e->getMessage();
  186. }
  187. }
  188. //.....................Customer....................//
  189.  
  190.  
  191. //.....................Property....................//
  192.  
  193. public function createPropertyTable()
  194. {
  195. $dbObj = new DBConfig();
  196. $conn = $dbObj->dbConnector();
  197. try {
  198. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  199. $table_create = "CREATE TABLE IF NOT EXISTS " . $dbObj->property_table . "(
  200. property_id INT AUTO_INCREMENT ,
  201. property_name VARCHAR(255),
  202. property_qnt INT,
  203. property_description VARCHAR(255),
  204. property_type VARCHAR(255),
  205. property_destination VARCHAR(255),
  206. single_property_value INT,
  207. property_value INT,
  208. property_date_of_purchase DATE,
  209. reference VARCHAR(255),
  210. supplier_id INT,
  211. update_time datetime,
  212. create_time datetime NOT NULL DEFAULT NOW(),
  213. PRIMARY KEY(property_id)
  214. )";
  215. $conn->exec($table_create);
  216. echo $dbObj->property_table . "Created Successfully";
  217. } catch (PDOException $e) {
  218. echo 'Table Not Creted' . $e->getMessage();
  219. }
  220. }
  221.  
  222. //.....................Property....................//
  223.  
  224. public function createSupplierTable()
  225. {
  226. $dbObj = new DBConfig();
  227. $conn = $dbObj->dbConnector();
  228. try {
  229. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  230. $table_create = "CREATE TABLE IF NOT EXISTS " . $dbObj->supplier_table . "(
  231. supplier_id INT AUTO_INCREMENT ,
  232. supplier_name VARCHAR(255),
  233. contact_person VARCHAR(255),
  234. supplier_contact_number INT,
  235. supplier_email VARCHAR(255),
  236. supplier_address VARCHAR(255),
  237. reference VARCHAR(255),
  238. update_time datetime,
  239. create_time datetime NOT NULL DEFAULT NOW(),
  240. PRIMARY KEY(supplier_id)
  241. )";
  242. $conn->exec($table_create);
  243. echo $dbObj->supplier_table . "Created Successfully";
  244. } catch (PDOException $e) {
  245. echo 'Table Not Creted' . $e->getMessage();
  246. }
  247. }
  248.  
  249. public function createPropertyTypeTable()
  250. {
  251. $dbObj = new DBConfig();
  252. $conn = $dbObj->dbConnector();
  253. try {
  254. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  255. $table_create = "CREATE TABLE IF NOT EXISTS " . $dbObj->property_type_table . "(
  256. property_type_id INT AUTO_INCREMENT ,
  257. property_name VARCHAR(255) UNIQUE,
  258. reference VARCHAR(255),
  259. update_time datetime,
  260. create_time datetime NOT NULL DEFAULT NOW(),
  261. PRIMARY KEY(property_type_id)
  262. )";
  263. $conn->exec($table_create);
  264. echo $dbObj->property_type_table . "Created Successfully";
  265. } catch (PDOException $e) {
  266. echo 'Table Not Creted' . $e->getMessage();
  267. }
  268. }
  269. //.....................Property....................//
  270.  
  271. ////.....................Property....................//
  272.  
  273. public function createDesignationTable()
  274. {
  275. $dbObj = new DBConfig();
  276. $conn = $dbObj->dbConnector();
  277. try {
  278. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  279. $table_create = "CREATE TABLE IF NOT EXISTS " . $dbObj->designation_table . "(
  280. designation_id INT AUTO_INCREMENT ,
  281. designation VARCHAR(255),
  282. reference VARCHAR(255),
  283. update_time datetime,
  284. create_time datetime NOT NULL DEFAULT NOW(),
  285. PRIMARY KEY(designation_id)
  286. )";
  287. $conn->exec($table_create);
  288. echo $dbObj->designation_table . "Created Successfully";
  289. } catch (PDOException $e) {
  290. echo 'Table Not Creted' . $e->getMessage();
  291. }
  292. }
  293. //.....................Property....................//
  294.  
  295.  
  296. //.....................Property....................//
  297.  
  298. public function createFoodTable()
  299. {
  300. $dbObj = new DBConfig();
  301. $conn = $dbObj->dbConnector();
  302. try {
  303. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  304. $table_create = "CREATE TABLE IF NOT EXISTS " . $dbObj->food_table . "(
  305. food_id INT AUTO_INCREMENT ,
  306. food_name VARCHAR(255),
  307. food_price INT,
  308. food_item_for VARCHAR(255),
  309. food_description TEXT,
  310. reference VARCHAR(255),
  311. update_time datetime,
  312. create_time datetime NOT NULL DEFAULT NOW(),
  313. PRIMARY KEY(food_id)
  314. )";
  315. $conn->exec($table_create);
  316. echo $dbObj->food_table . "Created Successfully";
  317. } catch (PDOException $e) {
  318. echo 'Table Not Creted' . $e->getMessage();
  319. }
  320. }
  321.  
  322. //.....................Property....................//
  323.  
  324.  
  325.  
  326. }
  327.  
  328. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement