public function add(Participant $participant) { $db = $this->connection(); $sql = "INSERT INTO {$this->dbTable} (" . self::$key . ", " . self::$name . ") VALUES (?, ?)"; $params = array($participant->getUnique(), $participant->getName()); $query = $db->prepare($sql); $query->execute($params); foreach ($participant->getProjects()->toArray() as $project) { $sql = "INSERT INTO " . self::$projectTable . " (" . self::$key . ", " . self::$name . ", participantUnique) VALUES (?, ?, ?)"; $query = $db->prepare($sql); $query->execute(array($project->getUnique(), $project->getName(), $participant->getUnique())); } }
/** * Check if a participant can be found within the list. * * @param \model\Participant $participant The needle to look for. * * @return Boolean */ public function contains(Participant $participant) { foreach ($this->portfolioOwners as $key => $owner) { if ($owner->getUnique() == $participant->getUnique() && $owner->getName() == $participant->getName()) { return true; } } return false; }