Example #1
0
 /**
  * Список всех значений фич, которые задействованы в данной категории маркетов
  * @param type $category_id
  * @param type $feature_ids
  * @return type
  */
 public static function getPossibleMarketsValues($category_id, $feature_ids)
 {
     $feature_ids = array_map('intval', $feature_ids);
     $feature_ids_imploded = implode(',', $feature_ids);
     $sql = 'SELECT fv.id, fv.feature_value ' . ' FROM ' . self::tableName() . ' fv ' . ' JOIN ' . FeaturesValuesRelations::tableName() . ' fvr ' . ' ON fv.id = fvr.feature_value_id ' . ' JOIN ' . MarketsFeatures::tableName() . ' mf ' . ' ON fv.id = mf.feature_value_id ' . ' JOIN ' . MarketsCategories::tableName() . ' mc ' . ' ON mc.markets_id = mf.markets_id ' . ' WHERE fvr.feature_id IN (' . $feature_ids_imploded . ') ' . ' AND mc.categories_id = :category_id';
     return self::findBySql($sql, [':category_id' => $category_id])->asArray()->all();
 }
Example #2
0
 /**
  * 
  * @param int|false $feature_id если false - брать все
  * @return array
  */
 public static function getPaginatedValues($feature_id)
 {
     $feature_id = (int) $feature_id;
     $sql = 'SELECT fv.id, fv.feature_value ' . ' FROM ' . self::tableName() . ' fv ' . ' LEFT JOIN ' . FeaturesValuesRelations::tableName() . ' fvr ' . ' ON fv.id = fvr.feature_value_id ';
     if ($feature_id) {
         $sql .= ' WHERE fvr.feature_id = ' . $feature_id;
     }
     $sql .= ' GROUP BY fv.id ';
     $query = self::findBySql($sql);
     self::$pages = new Pagination(['totalCount' => $query->count()]);
     self::$pages->setPageSize(self::VALUES_PER_PAGE);
     return $query->offset(self::$pages->offset)->limit(self::$pages->limit)->asArray()->all();
 }
Example #3
0
 public static function getByValue($value_id)
 {
     $sql = 'SELECT f.id, f.name ' . ' FROM ' . self::tableName() . ' f ' . ' JOIN ' . FeaturesValuesRelations::tableName() . ' fvr ' . ' ON f.id = fvr.feature_id ' . ' WHERE fvr.feature_value_id = :value_id';
     return self::findBySql($sql, [':value_id' => $value_id])->asArray()->all();
 }