function testConstructor() { $test_MasterScheduleEntry = new MasterScheduleEntry("weekly", "Mon", "odd", 14, 17, 2, "joe2071234567,sue2079876543", "I like pie.", "Night Shift"); echo "Testing first name" . '</br>'; if ($test_MasterScheduleEntry->get_MS_ID() == "weeklyMon14-17") { echo 'MS_ID test succeeded </br>'; } else { echo 'MS_ID test failed </br>'; } if ($test_MasterScheduleEntry->get_Schedule_type() == "weekly") { echo 'Schedule_type test succeeded </br>'; } else { echo 'Schedule_type test failed </br>'; } if ($test_MasterScheduleEntry->get_day() == "Mon") { echo 'day test succeeded </br>'; } else { echo 'day test failed </br>'; } if ($test_MasterScheduleEntry->get_Week_no() == "odd") { echo 'Week_no test succeeded </br>'; } else { echo 'Week_no test failed </br>'; } if ($test_MasterScheduleEntry->get_start_time() == 14) { echo 'start time test succeeded </br>'; } else { echo 'start time test failed </br>'; } if ($test_MasterScheduleEntry->get_end_time() == 17) { echo 'end time test succeeded </br>'; } else { echo 'end time test failed </br>'; } if ($test_MasterScheduleEntry->get_slots() == 2) { echo 'slot test succeeded </br>'; } else { echo 'slot test failed </br>'; } if ($test_MasterScheduleEntry->get_persons() == "joe2071234567,sue2079876543") { echo 'persons test succeeded </br>'; } else { echo 'persons test failed </br>'; } if ($test_MasterScheduleEntry->get_notes() == "I like pie.") { echo 'note test succeeded </br>'; } else { echo 'note test failed </br>'; } if ($test_MasterScheduleEntry->get_Shifts() == "Night Shift") { echo 'Shifts test succeeded </br>'; } else { echo 'Shifts test failed </br>'; } }
function insert_dbMasterSchedule(MasterScheduleEntry $entry) { connect(); $result = mysql_query("SELECT * FROM MASTERSCHEDULE WHERE MS_ID = '" . $entry->get_MS_ID() . "'"); if (!$result) { error_log('ERROR on select in insert_dbMasterSchedule() ' . mysql_error()); die('Invalid query: ' . mysql_error()); } if (mysql_num_rows($result) != 0) { delete_dbMasterSchedule($entry->get_MS_ID()); connect(); } $query = "INSERT INTO MASTERSCHEDULE VALUES ('" . $entry->get_MS_ID() . "','" . $entry->get_Schedule_type() . "','" . $entry->get_day() . "','" . $entry->get_start_time() . "','" . $entry->get_end_time() . "','" . $entry->get_slots() . "','" . $entry->get_notes() . "','" . $entry->get_Shifts() . "');"; //TODO: Log in a separate file //error_log("in insert into master schedule, query is " . $query); $result = mysql_query($query); if (!$result) { error_log('ERROR on select in insert_dbMasterSchedule() ' . mysql_error() . " - Unable to insert in MASTERSCHEDULE: " . $entry->get_MS_ID()); mysql_close(); return false; } mysql_close(); return true; }