/** * Determines if this object is the same as that passed in. * * @param Model_Insurance_Answer $otherAnswer * The answer object to compare against. * * @return boolean * True if the objects are the same, false otherwise. */ public function equals($otherAnswer) { $isCopy = false; //Begin the comparison process. if ($this->_policyNumber == $otherAnswer->getPolicyNumber()) { if ($this->_questionNumber == $otherAnswer->getQuestionNumber()) { if ($this->_answer == $otherAnswer->getAnswer()) { if ($this->_dateAnswered->compareDate($otherAnswer->getDateAnswered()) == 0) { $isCopy = true; } } } } return $isCopy; }
/** * Determines if an answer has been stored. * * This method will determine if the UW answer passed in has already been * stored in the database. Will return true or false accordingly. Will search on * all aspects of the answer. * * @param Model_Insurance_Answer $answer The answer to search for in the database. * @param bool $isAnswerIncluded (default true) Flag to determine whether the answer is included in the check * @return bool True if the answer has been previously stored, false otherwise. */ public function getExists($answer, $isAnswerIncluded = true) { $select = $this->select(); $select->where('policyNumber = ?', $answer->getPolicyNumber()); $select->where('questionID = ?', $answer->getQuestionNumber()); if ($isAnswerIncluded) { $select->where('answerGiven = ?', $answer->getAnswer()); } $select->where('dateAnswered = ?', $answer->getDateAnswered()->toString('YYYY-MM-dd')); $rowSet = $this->fetchAll($select); if (count($rowSet) >= 1) { return true; } // No warning given as this is a common/normal scenario return false; }