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(); } } }