コード例 #1
0
 public function applyCondition(IKalturaDbQuery $query)
 {
     if (is_null($this->categoriesMatchOr) && is_null($this->categoryIdEqual)) {
         return;
     }
     // Fetch the list of categories
     $categoryEntries = null;
     if ($this->categoriesMatchOr) {
         $categoryEntries = entryFilter::categoryFullNamesToIdsParsed($this->categoriesMatchOr, $this->categoryEntryStatusIn);
     } else {
         $categoryEntries = entryFilter::categoryIdsToSphinxIds($this->categoryIdEqual, $this->categoryEntryStatusIn);
     }
     if ($categoryEntries == '') {
         // Set a non-exiting cat. id. in order to return empty results (instead of throwing an exception)
         $categoryEntries = category::CATEGORY_ID_THAT_DOES_NOT_EXIST;
     }
     $categoryEntries = explode(',', $categoryEntries);
     $query->addColumnWhere(entryPeer::CATEGORIES_IDS, $categoryEntries, KalturaCriteria::IN_LIKE);
     if ($this->orderBy) {
         $orderByField = substr($this->orderBy, 1);
         $orderBy = $this->orderBy[0] == '+' ? Criteria::ASC : Criteria::DESC;
         if ($orderByField != self::CREATED_AT) {
             throw new kCoreException("Unsupported orderBy criteria [{$orderByField}]");
         }
         $dynAttribCriteriaFieldName = entryIndex::DYNAMIC_ATTRIBUTES . '.' . self::getCategoryCreatedAtDynamicAttributeName($this->categoryIdEqual);
         $query->addNumericOrderBy($dynAttribCriteriaFieldName, $orderBy);
     }
 }