dbraw.php 594 B

123456789101112131415161718192021222324
  1. <?php
  2. function dbraw($pdo)
  3. {
  4. static $statement;
  5. $statement = $statement ?? $pdo->prepare('SELECT id,randomNumber FROM World WHERE id = ?');
  6. if ( ! isset($_GET['queries'])) {
  7. $statement->execute([mt_rand(1, 10000)]);
  8. return json_encode($statement->fetch(PDO::FETCH_ASSOC));
  9. }
  10. $query_count = 1;
  11. if ($_GET['queries'] > 1) {
  12. $query_count = min($_GET['queries'], 500);
  13. }
  14. while ($query_count--) {
  15. $statement->execute([mt_rand(1, 10000)]);
  16. $arr[] = $statement->fetch(PDO::FETCH_ASSOC);
  17. }
  18. return json_encode($arr);
  19. }