Table.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CatchAdmin [Just Like ~ ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
  8. // +----------------------------------------------------------------------
  9. // | Author: JaguarJack [ njphper@gmail.com ]
  10. // +----------------------------------------------------------------------
  11. namespace catcher\library\crontab;
  12. use Swoole\Table as STable;
  13. trait Table
  14. {
  15. /**
  16. * @var STable
  17. */
  18. protected $table;
  19. protected function createTable()
  20. {
  21. $this->table = new STable(1024);
  22. $this->table->column('pid', STable::TYPE_INT, 4); //1,2,4,8
  23. $this->table->column('memory', STable::TYPE_INT, 4);
  24. $this->table->column('start_at', STable::TYPE_INT, 8);
  25. $this->table->column('running_time', STable::TYPE_INT, 8);
  26. $this->table->column('status', STable::TYPE_STRING, 15);
  27. $this->table->column('deal_tasks', STable::TYPE_INT, 4);
  28. $this->table->column('errors', STable::TYPE_INT, 4);
  29. $this->table->create();
  30. }
  31. protected function addColumn($pid, $value)
  32. {
  33. return $this->table->set($pid, $value);
  34. }
  35. }