/** * Sauvegarde ou met a jour l'item passé. * @param \Commun\Model\Items $oItems * @return \Core\Model\Items */ public function saveOrUpdateItem($oItems) { try { $oTabItem = $this->selectBy(array('idBnet' => $oItems->getIdBnet())); } catch (\Exception $exc) { throw new DatabaseException(3000, 4, $this->_getServiceLocator(), $oItems->getArrayCopy(), $exc); } //si il existe pas on le cree if (!$oTabItem) { try { $oTabItem = new \Commun\Model\Items(); $oTabItem->setAjouterPar("Import Raid-TracKer"); $oTabItem->setNom(strtolower($oItems->getNom())); $oTabItem->setIcon($oItems->getIcon()); $oTabItem->setIdBnet($oItems->getIdBnet()); $this->insert($oTabItem); $oTabItem->setIdItem($this->lastInsertValue); } catch (\Exception $exc) { throw new DatabaseException(3000, 2, $this->_getServiceLocator(), $oItems->getArrayCopy(), $exc); } } return $oTabItem; }
/** * Sauvegarde ou met a jour le personnage et le raid passé. * @param \Commun\Model\Personnages $oPersonnage * @param \Commun\Model\Raids $oRaids * @param \Commun\Model\Items $oItems * @param string $sNomBoss * @param string $sBonus * @param string $sNote * @param date $dDateLoot date du loot * @return \Core\Model\RaidPersonnage */ public function saveOrUpdateItemPersonnageRaid($oPersonnage, $oRaids, $oItems, $sNomBoss, $sBonus, $sNote, $dDateLoot) { try { $oItemPersonnageRaid = new \Commun\Model\ItemPersonnageRaid(); $oItemPersonnageRaid->setIdItem($oItems->getIdItem()); $oItemPersonnageRaid->setIdRaid($oRaids->getIdRaid()); $oItemPersonnageRaid->setIdPersonnage($oPersonnage->getIdPersonnage()); $oItemPersonnageRaid->setBonus($sBonus); $oItemPersonnageRaid->setDate($dDateLoot); $oBoss = $this->_getTableBoss()->selectBy(array('nom' => strtolower($sNomBoss))); if (!$oBoss) { throw new DatabaseException(9000, 6, $this->_getServiceLocator(), array(strtolower($sNomBoss))); } $oItemPersonnageRaid->setIdBosses($oBoss->getIdBosses()); $oItemPersonnageRaid->setNote($sNote); $this->insert($oItemPersonnageRaid); return $oItemPersonnageRaid; } catch (\Exception $ex) { throw new DatabaseException(8000, 2, $this->_getServiceLocator(), array($oPersonnage, $oRaids, $oItems, $sNomBoss, $sBonus, $sNote, $dDateLoot), $ex); } }