Ejemplo n.º 1
0
 /**
  * Load a list of titles into the collection cache
  *
  * @param array $titles
  */
 public function loadCollectionCache(array $titles)
 {
     /*
      * If we already have everything in our memory, do not
      * bother with trying to find any more records in the database
      */
     if (self::$startedWithFullCacheLoad) {
         return;
     }
     // if
     /*
      * If we get an empty list of titles to fetch, fetch everything
      * else just the list we want to return
      */
     if (!empty($titles)) {
         $sqlWhere = " mc.title IN (" . $this->_conn->arrayKeyToIn($titles, PDO::PARAM_STR) . ")";
         self::$startedWithFullCacheLoad = false;
     } else {
         $sqlWhere = ' (1 = 1)';
         self::$startedWithFullCacheLoad = true;
     }
     // else
     /* Retrieve the current list */
     $resultList = $this->_conn->arrayQuery("SELECT mc.id AS mcid,\n                                                           c.id AS cid,\n                                                           mc.title,\n                                                           mc.tmdb_id,\n                                                           mc.tvrage_id,\n                                                           mc.cattype,\n                                                           mc.year AS year,\n                                                           c.season,\n                                                           c.episode,\n                                                           c.partscurrent,\n                                                           c.partstotal\n                                                    FROM mastercollections mc\n                                                        LEFT JOIN collections c ON c.mcid = mc.id\n\t\t\t\t\t\t\t\t\t\t\t\t    WHERE " . $sqlWhere);
     // and merge it into the cache
     foreach ($resultList as $result) {
         $collection = new Dto_CollectionInfo($result['cattype'], $result['title'], $result['season'], $result['episode'], $result['year'], $result['partscurrent'], $result['partstotal']);
         $collection->setMcId($result['mcid']);
         $collection->setId($result['cid']);
         /*
          * Make sure the master record is in the local cache
          */
         if (!$this->isInLocalCache($result['title'], $result['cattype'], $result['year'])) {
             $this->addMcToLocalCache($result['mcid'], $result['title'], $result['cattype'], $result['year']);
         }
         // if
         /*
          * And add it to the local cache array
          */
         $this->addSpecificCollectionToLocalCache($collection->getTitle(), $collection->getCatType(), $collection->getYear(), $collection);
     }
     // foreach
 }