Cron.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. *
  9. * ----------------------------------------------------------------------------
  10. *
  11. * ============================================================================
  12. * 数据层模型
  13. */
  14. class Cron extends BaseModel {
  15. /**
  16. * 取单条任务信息
  17. * @access public
  18. * @author csdeshang
  19. * @param array $condition 检索条件
  20. * @return type
  21. */
  22. public function getCronInfo($condition = array()) {
  23. return Db::name('cron')->where($condition)->find();
  24. }
  25. /**
  26. * 任务队列列表
  27. * @access public
  28. * @author csdeshang
  29. * @param array $condition 检索条件
  30. * @param number $limit 数目限制
  31. * @return array
  32. */
  33. public function getCronList($condition, $limit = 100) {
  34. return Db::name('cron')->where($condition)->limit($limit)->select()->toArray();
  35. }
  36. /**
  37. * 保存任务队列
  38. * @access public
  39. * @author csdeshang
  40. * @param unknown $data 参数内容
  41. * @return array
  42. */
  43. public function addCronAll($data) {
  44. return Db::name('cron')->insertAll($data);
  45. }
  46. /**
  47. * 保存任务队列
  48. * @access public
  49. * @author csdeshang
  50. * @param array $data 参数内容
  51. * @return boolean
  52. */
  53. public function addCron($data) {
  54. return Db::name('cron')->insert($data);
  55. }
  56. /**
  57. * 删除任务队列
  58. * @access public
  59. * @author csdeshang
  60. * @param array $condition 条件
  61. * @return array
  62. */
  63. public function delCron($condition) {
  64. return Db::name('cron')->where($condition)->delete();
  65. }
  66. }