25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

69 lines
1.4 KiB

  1. <?php
  2. namespace backend\modules\api\models;
  3. use Yii;
  4. use yii\base\Exception;
  5. /**
  6. * This is the model class for table "lvmama_push_info".
  7. *
  8. * @property integer $id
  9. * @property string $create_time
  10. * @property string $type
  11. * @property string $msg
  12. */
  13. class LvmamaPushInfo extends \yii\db\ActiveRecord
  14. {
  15. /**
  16. * @inheritdoc
  17. */
  18. public static function tableName()
  19. {
  20. return 'lvmama_push_info';
  21. }
  22. /**
  23. * @inheritdoc
  24. */
  25. public function rules()
  26. {
  27. return [
  28. [['create_time', 'type'], 'string', 'max' => 20],
  29. [['msg'], 'string', 'max' => 500],
  30. ];
  31. }
  32. /**
  33. * @inheritdoc
  34. */
  35. public function attributeLabels()
  36. {
  37. return [
  38. 'id' => 'ID',
  39. 'create_time' => 'Create Time',
  40. 'type' => 'Type',
  41. 'msg' => 'Msg',
  42. ];
  43. }
  44. public function istPush($type,$msg){
  45. $values=[
  46. 'create_time'=>date('Y-m-d H:i:s'),
  47. 'type'=>$type,
  48. 'msg'=>$msg
  49. ];
  50. $transaction=Yii::$app->db->beginTransaction();
  51. try{
  52. $this->attributes=$values;
  53. $res=$this->insert();
  54. if(!$res){
  55. throw new Exception('添加出错');
  56. }
  57. $transaction->commit();
  58. }catch (Exception $e){
  59. $transaction->rollBack();
  60. }
  61. }
  62. }