skeeks\cms\models\CmsContentElementProperty::tableName PHP Method

tableName() public static method

public static tableName ( )
    public static function tableName()
    {
        return '{{%cms_content_element_property}}';
    }

Usage Example

コード例 #1
0
 /**
  * @param ActiveDataProvider $activeDataProvider
  */
 public function search(ActiveDataProvider $activeDataProvider)
 {
     /**
      * @var $activeQuery ActiveQuery
      */
     $activeQuery = $activeDataProvider->query;
     //$activeQuery->leftJoin('cms_content_element_property', '`cms_content_element_property`.`element_id` = `cms_content_element`.`id`');
     $elementIdsGlobal = [];
     $applyFilters = false;
     foreach ($this->toArray() as $propertyCode => $value) {
         if ($property = $this->getProperty($propertyCode)) {
             if ($property->property_type == \skeeks\cms\relatedProperties\PropertyType::CODE_NUMBER) {
                 $elementIds = [];
                 $query = (new \yii\db\Query())->from(CmsContentElementProperty::tableName())->select(['element_id'])->where(["property_id" => $property->id]);
                 if ($fromValue = $this->{$this->getAttributeNameRangeFrom($propertyCode)}) {
                     $applyFilters = true;
                     $query->andWhere(['>=', 'value_num', (double) $fromValue]);
                 }
                 if ($toValue = $this->{$this->getAttributeNameRangeTo($propertyCode)}) {
                     $applyFilters = true;
                     $query->andWhere(['<=', 'value_num', (double) $toValue]);
                 }
                 if (!$fromValue && !$toValue) {
                     continue;
                 }
                 $elementIds = $query->all();
             } else {
                 if (!$value) {
                     continue;
                 }
                 $applyFilters = true;
                 $elementIds = (new \yii\db\Query())->from(CmsContentElementProperty::tableName())->select(['element_id'])->where(["value" => $value, "property_id" => $property->id])->all();
             }
             $elementIds = \yii\helpers\ArrayHelper::map($elementIds, "element_id", "element_id");
             if (!$elementIds) {
                 $elementIdsGlobal = [];
             }
             if ($elementIdsGlobal) {
                 $elementIdsGlobal = array_intersect_assoc($elementIds, $elementIdsGlobal);
             } else {
                 $elementIdsGlobal = $elementIds;
             }
         }
     }
     if ($applyFilters) {
         $activeQuery->andWhere(['cms_content_element.id' => $elementIdsGlobal]);
     }
 }
All Usage Examples Of skeeks\cms\models\CmsContentElementProperty::tableName