Main.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php declare(strict_types=1);
  2. /**
  3. * DuckPhp
  4. * From this time, you never be alone~
  5. */
  6. namespace DuckPhpBenchmark\Controller;
  7. use DuckPhpBenchmark\System\Helper\ControllerHelper as C;
  8. use DuckPhpBenchmark\Business\DbBusiness;
  9. class Main
  10. {
  11. public function index()
  12. {
  13. echo 'hello! duckphp: '. DATE(DATE_ATOM);
  14. }
  15. // change if you can
  16. public function plaintext()
  17. {
  18. C::header('Content-Type: text/plain; charset=utf-8');
  19. echo 'Hello, World!';
  20. }
  21. public function json()
  22. {
  23. $ret = [
  24. 'message' => 'Hello, World!',
  25. ];
  26. C::ExitJson($ret);
  27. }
  28. public function db()
  29. {
  30. $ret = DbBusiness::G()->getRandomRow();
  31. C::DbCloseAll();
  32. C::ExitJson($ret);
  33. }
  34. public function updates()
  35. {
  36. $queries = (int) C::GET('queries',1);
  37. $query_count = 1;
  38. if ($queries > 1) {
  39. $query_count = min($queries, 500);
  40. }
  41. $ret = DbBusiness::G()->multiUpdate($query_count);
  42. C::DbCloseAll();
  43. C::ExitJson($ret);
  44. }
  45. public function queries()
  46. {
  47. $queries = (int) C::GET('queries',1);
  48. $query_count = 1;
  49. if ($queries > 1) {
  50. $query_count = min($queries, 500);
  51. }
  52. $ret = DbBusiness::G()->multiQuery($query_count);
  53. C::DbCloseAll();
  54. C::ExitJson($ret);
  55. }
  56. public function fortunes()
  57. {
  58. $arr = DbBusiness::G()->getFortunes();
  59. C::DbCloseAll();
  60. C::Show(get_defined_vars(),'fortunes');
  61. }
  62. }