updateraw.php 692 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. $update = '';
  11. while ($query_count--) {
  12. $id = mt_rand(1, 10000);
  13. $statement->execute([$id]);
  14. $world = ['id' => $id, 'randomNumber' => $statement->fetchColumn()];
  15. $world['randomNumber'] = mt_rand(1, 10000);
  16. $update .= "UPDATE World SET randomNumber={$world['randomNumber']} WHERE id=$id;";
  17. $arr[] = $world;
  18. }
  19. $pdo->exec($update);
  20. return json_encode($arr, JSON_NUMERIC_CHECK);
  21. }