$city = trim($tmp[sizeof($tmp) - 1], " "); // default values if (empty($openingHour)) { $openingHour = '00:00:00'; } if (empty($closingHour)) { $closingHour = '23:59:59'; } if (empty($slots)) { $slots = -1; } $db = connect(); try { // using a transaction to preserve the database integrity $db->beginTransaction(); insertSegment($db, $name, $slots, $lng, $lat, $city); // the key of the newly added segment is needed as a foreign key for the following queries $id = $db->lastInsertId(); // we need to create a default name if the name wasn't filled in the form if (empty($name)) { $name = 'Parking #' . $id; updateName($db, $id, $name); } insertEntranceAdress($db, $entrance, $id); insertWalkingAdress($db, $walking, $id); insertExitAdress($db, $exit, $id); insertOpeningHours($db, $openingHour, $closingHour, $id); insertPaymentType($db, $payment, $id); insertParkLot($db, $name, $city); insertFeatures($db, $id, $features); $db->commit();
insertAnsOpt(1, 1, 1); insertAnsOpt(2, 3, 1); insertAnsOpt(7, 4, 1); insertOption(2, 'No', 2, 1); insertAnsOpt(3, 2, 2); insertQuestion(2, 'How much do you like kinder eggs?', 1); insertOption(3, 'Lot', 1, 2); insertAnsOpt(4, 1, 3); insertAnsOpt(5, 3, 3); insertAnsOpt(8, 4, 3); insertOption(4, 'Medium', 2, 2); insertAnsOpt(6, 2, 4); insertOption(5, 'Low', 3, 2); insertSegment('GENDER', 0, 1); insertSegment('AGE', 0, 1); insertSegment('AGE', 1, 1); // Insert statistic insertStatistic(1, 'Interesting 2D...', 1, 1, getNextDate($phpdate)); insertUVar(1, 1, 'RELIGION', 0); insertQVar(1, 1, 1, 1); insertStatistic(2, 'Interesting 3D...', 1, 1, $dates[0]); insertUVar(2, 2, 'GENDER', 0); insertQVar(2, 2, 1, 1); insertQVar(3, 2, 2, 2); insertStatistic(3, 'Not so interesting (1D)...', 1, 1, $dates[3]); insertUVar(3, 3, 'AGE', 0); insertTracking(1, 2, true, $dates[1]); insertTracking(1, 3, false, getNextDate($phpdate)); insertTracking(2, 1, true, getNextDate($phpdate)); insertTracking(2, 3, false, getNextDate($phpdate)); insertTracking(3, 4, true, getNextDate($phpdate));