function testdbDatesModule() { $my_shifts = array(); $my_shifts[] = new Shift("10-02-28:9-1", "house", 1, array(), array(), null, ""); $my_shifts[] = new Shift("10-02-28:1-5", "house", 1, array(), array(), null, ""); $my_date = new RMHdate("10-02-28", "house", $my_shifts, ""); $this->assertTrue(insert_dbDates($my_date)); $this->assertTrue(delete_dbDates($my_date)); echo "testdbDates complete"; }
function test_get_shifts_text() { $newDate = new BSCAHdate("01-01-15", "9-11", "notes", []); $nd = insert_dbDates($newDate); echo 'will test get_shifts_text</br>'; $result = get_shifts_text($newDate); if ($result == null) { echo 'get_shifts_text failed</br>'; } else { echo 'get_shifts_text succeeded</br>'; } $res = delete_dbDates($newDate); if ($res == null) { echo 'Delete failed</br>'; } }
/** * updates a date in the dbDates table */ function update_dbDates($d) { if (!$d instanceof BSCAHdate) { die("Invalid argument for date->update_dbDates function call"); } delete_dbDates($d); insert_dbDates($d); return true; }
/** * Deletes a week from the db * * @param $w Week the week to delete */ function delete_dbWeeks($w) { if (!$w instanceof Week) { die("Invalid argument for delete_dbWeeks function call"); } connect(); $query = "DELETE FROM WEEKS WHERE ID=\"" . $w->get_id() . "\""; error_log('in delete_dbWeeks query is ' . $query); $result = mysql_query($query); mysql_close(); if (!$result) { error_log("unable to delete from week: " . $w->get_id() . mysql_error()); return false; } foreach ($w->get_dates() as $i) { delete_dbDates($i); } return true; }
/** * Deletes a week from the db * @param $w the week to delete */ function delete_dbWeeks($w) { if (!$w instanceof Week) { die("Invalid argument for delete_dbWeeks function call"); } connect(); $query = "DELETE FROM dbWeeks WHERE id=\"" . $w->get_id() . "\""; $result = mysql_query($query); mysql_close(); if (!$result) { echo "unable to delete from dbWeeks: " . $w->get_id() . mysql_error(); return false; } else { foreach ($w->get_dates() as $i) { delete_dbDates($i); } } return true; }