public function delete($code) { try { $c = DatabaseConnection::getConnection(); if (self::exists($code) == false) { throw new DAOException("DepartmentDAO : delete : Invalid code " . $code); } $memberDAO = new MemberDAO(); if ($memberDAO->getCountByDepartment($code) > 0) { throw new DAOException("DepartmentDAO : delete : Department used against some member(s) " . $code); } $ps = $c->prepare("delete from tbl_department where code = ?"); $ps->bindParam(1, $code); $ps->execute(); $ps = null; $c = null; } catch (Exception $exception) { throw new DAOException("DepartmentDAO : delete : " . $exception->getMessage()); } }