dbraw.php 607 B

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