|
- <?php
-
- namespace backend\modules\api\models;
-
- use Yii;
- use yii\base\Exception;
-
- /**
- * This is the model class for table "lvmama_push_info".
- *
- * @property integer $id
- * @property string $create_time
- * @property string $type
- * @property string $msg
- */
- class LvmamaPushInfo extends \yii\db\ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return 'lvmama_push_info';
- }
-
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['create_time', 'type'], 'string', 'max' => 20],
- [['msg'], 'string', 'max' => 500],
- ];
- }
-
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'create_time' => 'Create Time',
- 'type' => 'Type',
- 'msg' => 'Msg',
- ];
- }
-
- public function istPush($type,$msg){
- $values=[
- 'create_time'=>date('Y-m-d H:i:s'),
- 'type'=>$type,
- 'msg'=>$msg
- ];
- $transaction=Yii::$app->db->beginTransaction();
- try{
- $this->attributes=$values;
- $res=$this->insert();
- if(!$res){
- throw new Exception('添加出错');
- }
- $transaction->commit();
- }catch (Exception $e){
- $transaction->rollBack();
- }
- }
- }
|