当前位置: 首页>>代码示例>>PHP>>正文


PHP Card::model方法代码示例

本文整理汇总了PHP中Card::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Card::model方法的具体用法?PHP Card::model怎么用?PHP Card::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Card的用法示例。


在下文中一共展示了Card::model方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cardInfo

 public function cardInfo($params = array())
 {
     extract($params);
     if (isset($type_id)) {
         $num = isset($num) && $num > 0 ? $num : 1;
         $result = Card::model()->getCards($type_id, $num);
         if ($result) {
             $ret = $this->notice('OK', 0, '成功', $result);
         } else {
             $ret = $this->notice('OK', 0, '成功', []);
         }
     } else {
         $ret = $this->notice('ERR', 301, '缺少参数', []);
     }
     return $ret;
 }
开发者ID:kl0428,项目名称:urtime,代码行数:16,代码来源:CardService.php

示例2: actionCreate

 public function actionCreate()
 {
     $model = new ConsumerLog();
     $model->unsetAttributes();
     if ($_POST['ConsumerLog']) {
         $model->attributes = $_POST['ConsumerLog'];
         if ($model->validate()) {
             $model->setAttribute('fee', $model->price / $model->total);
             if ($model->save() && Card::model()->updateByPk($model->card_id, ['used_num' => $model->used + 1])) {
                 Yii::app()->user->setFlash('ConsumerLog', '提交成功');
             }
         }
     }
     $stores = Store::model()->getName();
     $this->render('create', ['model' => $model, 'stores' => $stores]);
 }
开发者ID:kl0428,项目名称:admin,代码行数:16,代码来源:ConsumerLogController.php

示例3: checkCard

 public function checkCard($attribute, $params)
 {
     if ($this->flag < 2) {
         if ($this->flag_content) {
             $obj = Card::model()->find(array('condition' => 'card_num=:num and is_sale =:sale', 'params' => array(':num' => $this->flag_content, ':sale' => '1')));
             if ($obj) {
                 if (strtotime($obj->start_time) > time()) {
                     $this->addError($attribute, '使用时间未开始');
                     return false;
                 }
                 if (strtotime($obj->end_time) < time()) {
                     $this->addError($attribute, '有效时间已过');
                     return false;
                 }
                 if ($obj->total_num > $obj->used_num) {
                     //ok
                     $this->total = $obj->total_num;
                     $this->used = $obj->used_num;
                     $this->price = $obj->price;
                     $this->card_id = $obj->card_id;
                     return true;
                 } else {
                     $this->addError($attribute, '次数已用完');
                 }
             } else {
                 $this->addError($attribute, '卡号不存在');
             }
         } else {
             $this->addError($attribute, '卡号不能为空');
         }
     } else {
         if ($this->flag == 2) {
             return true;
         } else {
             $this->addError($attribute, '卡号不存在');
         }
     }
 }
开发者ID:kl0428,项目名称:admin,代码行数:38,代码来源:ConsumerLog.php

示例4: loadModel

 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Card the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Card::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
开发者ID:RooneyAbd,项目名称:phonebook,代码行数:15,代码来源:CardController.php

示例5: actionDeleteCard

 public function actionDeleteCard()
 {
     $id = $this->_get("id");
     if ($id) {
         if (Card::model()->deleteByPk($id)) {
             Yii::app()->user->setFlash('Card', '删除成功');
             $this->redirect(array('card/card'));
         }
     } else {
         $this->redirect(array('card/card'));
     }
 }
开发者ID:kl0428,项目名称:admin,代码行数:12,代码来源:CardController.php


注:本文中的Card::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。