Switches.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * 后台开关相关
  4. * Date: 2017/9/5 0005
  5. * Time: 18:48
  6. */
  7. defined( 'IN_WEB') or die( 'Include Error!');
  8. class Switches{
  9. /**
  10. * 获取开关
  11. */
  12. public function getList(){
  13. $tb = otable::configSwitch();
  14. $sql = " SELECT * FROM {$tb} WHERE 1";
  15. $ret = oo::commonOprDb('common')->getAll($sql, MYSQLI_ASSOC);
  16. return json_encode($ret);
  17. }
  18. /**
  19. * 更新开关,顺便删除缓存
  20. */
  21. public function actionswi($param){
  22. $id = intval($param['id']);
  23. $status = intval($param['status']);
  24. $tb = otable::configSwitch();
  25. $sql = "UPDATE {$tb} SET status={$status} WHERE id={$id} LIMIT 1";
  26. oo::commonOprDb('common')->query($sql);
  27. oo::commonOprRedis('common')->delete(okeys::configSwitch($id));
  28. }
  29. /**
  30. * 获取开关
  31. */
  32. public function getBullet(){
  33. $tb = otable::configBullet();
  34. $sql = " SELECT * FROM {$tb} WHERE 1";
  35. $ret = oo::commonOprDb('common')->getAll($sql, MYSQLI_ASSOC);
  36. return json_encode($ret);
  37. }
  38. /**
  39. * 更新开关,顺便删除缓存
  40. */
  41. public function actionBullet($param){
  42. $id = intval($param['id']);
  43. $status = intval($param['status']);
  44. $tb = otable::configBullet();
  45. $sql = "UPDATE {$tb} SET status={$status} WHERE id={$id} LIMIT 1";
  46. oo::commonOprDb('common')->query($sql);
  47. oo::commonOprRedis('common')->delete(okeys::configSwitch($id));
  48. }
  49. }