Example #1
0
 public function deleteByField($field, $value = null)
 {
     if (is_array($field)) {
         $items = $this->getByField($field, $this->id);
     } else {
         $items = $this->getByField($field, $value, $this->id);
     }
     $res = false;
     if ($ids = array_keys($items)) {
         $res = parent::deleteByField($this->id, $ids);
         if ($res) {
             $type_upselling_model = new shopTypeUpsellingModel();
             $type_upselling_model->deleteByField('feature_id', $ids);
             $params_model = new shopProductFeaturesModel();
             $params_model->deleteByField('feature_id', $ids);
             $types = $this->groupByValueType($items);
             foreach ($types as $type => $type_ids) {
                 if ($model = self::getValuesModel($type)) {
                     $model->deleteByField('feature_id', $type_ids);
                 }
             }
             $this->deleteByField('parent_id', $ids);
         }
     }
     return $res;
 }
 public function deleteByField($field, $value = null)
 {
     $post_category_model = new blogCategoryPostModel();
     if ($field == $this->id) {
         $ids = $value;
     } else {
         $ids = $this->select($this->id)->where($this->getWhereByField($field, $value))->fetchAll();
     }
     $post_category_model->deleteByField('category_id', $ids);
     parent::deleteByField($field, $value);
 }