public function deletegroupAction() { $groupID = $this->_request->getParam('g'); $group_DB = new Application_Model_DbTable_Group(); $student_DB = new Application_Model_DbTable_StudentsInField(); $students = $student_DB->getAll($groupID); foreach ($students as $s) { $data = array('groupID' => NULL); $studentID = $s['id']; $student_DB->update($data, "id = {$studentID}"); } $group_DB->delete("groupID = {$groupID}"); $this->_redirect("/managegroups"); }