public function remove() { if (!$this->exists()) { return false; } // Remove all of the user's surveys foreach ($this->surveys as $surveyID) { $survey = new Survey($surveyID); $survey->remove(); } // And the container which references them Redis::del("User:{$this->id}:surveys"); // And the username-userid reference Redis::set("User:username:{$this->username}"); parent::remove(); }
public function remove() { if (!$this->exists()) { return false; } // Find all of the keys used to store answers $answerKeys = array(); foreach ($this->questions as $questionID => $question) { foreach ($question['answers'] as $answerID => $answer) { $answerKeys[] = "Survey:{$this->id}:{$questionID}:{$answerID}"; } } // Remove all of the answer sets if (count($answerKeys)) { call_user_func_array(array('Redis', 'del'), $answerKeys); } parent::remove(); }