function testdbCrewsModule() { $s1 = new Crew("13-10-20", "foodpantry", 3, null, "", ""); $this->assertTrue(insert_dbCrews($s1)); $this->assertEqual(select_dbCrews($s1->get_id())->get_date(), $s1->get_date()); $this->assertTrue(delete_dbCrews($s1->get_id())); $s2 = new Crew("13-10-21", "foodbank", 3, null, "", ""); $this->assertTrue(insert_dbCrews($s2)); $s2 = new Crew("13-10-21", "foodbank", 2, null, "", ""); $this->assertTrue(update_dbCrews($s2)); $this->assertTrue(delete_dbCrews($s2->get_id())); echo "testdbCrews complete"; }
function delete_dbMonths($month) { connect(); $query = "DELETE FROM dbMonths WHERE id=\"" . $month->get_id() . "\""; $result = mysql_query($query); mysql_close(); if (!$result) { echo mysql_error() . " unable to delete from dbMonths: " . $month->get_id(); return false; } foreach ($month->get_crews() as $crew_id) { delete_dbCrews($crew_id); } return true; }
/** * Updates a crew in the db by deleting it (if it exists) and then replacing it * @param $s the crew to update */ function update_dbCrews($s) { if (!$s instanceof Crew) { die("Invalid argument for dbCrews->replace_crew function call"); } delete_dbCrews($s->get_id()); insert_dbCrews($s); return true; }