protected function save($type) { $value = waRequest::post($type); $product = new shopProduct($this->product_id); $product->save(array($type => $value)); if ($value != 2) { $related_model = new shopProductRelatedModel(); $related_model->deleteByField(array('product_id' => $this->product_id, 'type' => $type)); } }