예제 #1
0
 /**
  * Return the list of Blocks of a given itemset
  * @param ItemSet $itemSet
  *
  * @return Block[]
  */
 public static function findAllByItemSet(ItemSet $itemSet)
 {
     $id = $itemSet->getId();
     $pdo = DatabaseManager::getConnection();
     $stmt = $pdo->prepare("SELECT * FROM block WHERE id_itemset = :id");
     $stmt->bindParam(':id', $id, \PDO::PARAM_INT);
     $stmt->execute();
     $array = $stmt->fetchAll();
     if ($array == false) {
         return [];
     }
     $blocks = [];
     foreach ($array as $data) {
         $block = new Block();
         $block->setId($data['id']);
         $block->setType($data['type']);
         $block->setRecMath(new \SplBool($data['recMath'] == 1 ? true : false));
         $block->setMinSummonerLevel(new \SplInt((int) $data['minSummonerLevel']));
         $block->setMaxSummonerLevel(new \SplInt((int) $data['maxSummonerLevel']));
         $api = ApiManager::getAPI();
         if ($data['showIfSummonerSpell'] != 0) {
             $block->setShowIfSummonerSpell($api->staticData()->getSummonerSpell($data['showIfSummonerSpell'], 'all'));
         }
         if ($data['hideIfSummonerSpell'] != 0) {
             $block->setHideIfSummonerSpell($api->staticData()->getSummonerSpell($data['hideIfSummonerSpell'], 'all'));
         }
         $block->setComment($data['comment']);
         $block->setItemSet($itemSet);
         $block->setItems(ItemBlock::findAllByBlock($block));
         $blocks[] = $block;
     }
     return $blocks;
 }
예제 #2
0
 /**
  * Return the items of an given Block
  * @param Block $block
  *
  * @return ItemBlock[]
  */
 public static function findAllByBlock(Block $block)
 {
     $id = $block->getId();
     $pdo = DatabaseManager::getConnection();
     $stmt = $pdo->prepare("SELECT * FROM itemblock WHERE id_block = :id");
     $stmt->bindParam(':id', $id, \PDO::PARAM_INT);
     $stmt->execute();
     $array = $stmt->fetchAll();
     if ($array == false) {
         return [];
     }
     $items = [];
     $api = ApiManager::getAPI();
     foreach ($array as $data) {
         $item = new ItemBlock();
         $item->setId($data['id']);
         $item->setItem($api->staticData()->getItem($data['item'], 'all'));
         $item->setCount(new \SplInt((int) $data['count']));
         $item->setBlock($block);
         $items[] = $item;
     }
     return $items;
 }
예제 #3
0
 /**
  * Give the list of item set
  * @return ItemSet[] list of ItemSet
  */
 public static function findAll()
 {
     $array = [];
     $pdo = DatabaseManager::getConnection();
     $stmt = $pdo->prepare("SELECT * FROM itemset ORDER BY id DESC ");
     $stmt->execute();
     while ($data = $stmt->fetch()) {
         $itemSet = new ItemSet();
         $itemSet->parseArray($data);
         $array[] = $itemSet;
     }
     return $array;
 }