model() public static method

Returns the static model of the specified AR class.
public static model ( string $className = __CLASS__ ) : ProductDiscount
$className string active record class name.
return ProductDiscount the static model class
示例#1
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();
 }
 public function actionUpdate()
 {
     $lid = Yii::app()->request->getParam('id');
     Until::isUpdateValid(array($lid), $this->companyId, $this);
     //0,表示企业任何时候都在云端更新。
     $model = ProductDiscount::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('ProductDiscount');
         $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('productSales/updatedetail', 'companyId' => $this->companyId, 'id' => $model->product_id));
         }
     }
     $this->render('update', array('model' => $model, 'product' => $product));
 }
 public function loadProductDiscount($id)
 {
     $this->_productdiscount = ProductDiscount::model()->findAll('product_id=:product_id', array(':product_id' => $id));
 }