updateraw.php 695 B

1234567891011121314151617181920212223242526
  1. <?php
  2. function updateraw()
  3. {
  4. global $pdo;
  5. $query_count = 1;
  6. if ($_GET['queries'] > 1) {
  7. $query_count = min($_GET['queries'], 500);
  8. }
  9. $statement = $pdo->prepare('SELECT randomNumber FROM World WHERE id=?');
  10. $updateStatement = $pdo->prepare('UPDATE World SET randomNumber=? WHERE id=?');
  11. while ($query_count--) {
  12. $id = mt_rand(1, 10000);
  13. $statement->execute([$id]);
  14. $world = ['id' => $id, 'randomNumber' => $statement->fetchColumn()];
  15. $updateStatement->execute(
  16. [$world['randomNumber'] = mt_rand(1, 10000), $id]
  17. );
  18. $arr[] = $world;
  19. }
  20. return json_encode($arr, JSON_NUMERIC_CHECK);
  21. }