model() public static method

Returns the static model of the specified AR class.
public static model ( string $className = __CLASS__ ) : ProductSpecial
$className string active record class name.
return ProductSpecial the static model class
 public function actionUpdate()
 {
     $lid = Yii::app()->request->getParam('id');
     Until::isUpdateValid(array($lid), $this->companyId, $this);
     //0,表示企业任何时候都在云端更新。
     $model = ProductSpecial::model()->find('lid=:lid and dpid=:dpid', array(':lid' => $lid, ':dpid' => $this->companyId));
     $product = Product::model()->find('lid=:lid and dpid=:dpid and delete_flag=0', array(':lid' => $model->product_id, ':dpid' => $this->companyId));
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = Yii::app()->request->getPost('ProductSpecial');
         $model->update_at = date('Y-m-d H:i:s', time());
         if ($model->save()) {
             Yii::app()->user->setFlash('success', yii::t('app', '修改成功'));
             $this->redirect(array('productSpecial/updatedetail', 'companyId' => $this->companyId, 'id' => $model->product_id));
         }
     }
     $this->render('update', array('model' => $model, 'product' => $product));
 }
Exemplo n.º 2
0
 public function afterDelete()
 {
     // delete dependencies
     ProductAttribute::model()->deleteAll("product_id={$this->cacheId}");
     ProductDescription::model()->deleteAll("product_id={$this->cacheId}");
     ProductDiscount::model()->deleteAll("product_id={$this->cacheId}");
     ProductFilter::model()->deleteAll("product_id={$this->cacheId}");
     ProductImage::model()->deleteAll("product_id={$this->cacheId}");
     ProductOption::model()->deleteAll("product_id={$this->cacheId}");
     ProductOptionValue::model()->deleteAll("product_id={$this->cacheId}");
     ProductRelated::model()->deleteAll("product_id={$this->cacheId}");
     ProductRelated::model()->deleteAll("related_id={$this->cacheId}");
     ProductReward::model()->deleteAll("product_id={$this->cacheId}");
     ProductSpecial::model()->deleteAll("product_id={$this->cacheId}");
     ProductToCategory::model()->deleteAll("product_id={$this->cacheId}");
     ProductToDownload::model()->deleteAll("product_id={$this->cacheId}");
     ProductToLayout::model()->deleteAll("product_id={$this->cacheId}");
     ProductToStore::model()->deleteAll("product_id={$this->cacheId}");
     Review::model()->deleteAll("product_id={$this->cacheId}");
     UrlAlias::model()->deleteAll("query='product_id={$this->cacheId}'");
     parent::afterDelete();
 }
Exemplo n.º 3
0
 public function loadProductSpecial($id)
 {
     $this->_productspecial = ProductSpecial::model()->findAll('product_id=:product_id', array(':product_id' => $id));
 }