Logs.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "os_logs".
  6. *
  7. * @property int $id
  8. * @property string $date
  9. * @property string $section
  10. * @property string $error_text
  11. */
  12. class Logs extends \yii\db\ActiveRecord
  13. {
  14. /**
  15. * {@inheritdoc}
  16. */
  17. public static function tableName()
  18. {
  19. return 'os_logs';
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public function rules()
  25. {
  26. return [
  27. [['date'], 'safe'],
  28. [['section', 'error_text'], 'required'],
  29. [['error_text'], 'string'],
  30. //[['section'], 'integer'],
  31. ];
  32. }
  33. public static function getDb()
  34. {
  35. return \Yii::$app->slave_db;
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function attributeLabels()
  41. {
  42. return [
  43. 'id' => 'ID',
  44. 'date' => 'Date',
  45. 'section' => 'Section',
  46. 'error_text' => 'Error Text',
  47. ];
  48. }
  49. public static function addlog($section,$text) {
  50. $logsModel = new Logs();
  51. $logsModel->section = $section;
  52. $logsModel->error_text = $text;
  53. $logsModel->save();
  54. //var_dump($logsModel->errors);
  55. }
  56. }