update-eloquent.php 756 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. require_once __DIR__ . '/boot-eloquent.php';
  3. // Read number of queries to run from URL parameter
  4. $query_count = 1;
  5. if (isset($_GET['queries']) && (int) $_GET['queries'] > 0) {
  6. $query_count = $_GET['queries'] > 500 ? 500 : $_GET['queries'];
  7. }
  8. // Create an array with the response string.
  9. $arr = array();
  10. // For each query, store the result set values in the response array
  11. while ($query_count--) {
  12. $id = mt_rand(1, 10000);
  13. $randomNumber = mt_rand(1, 10000);
  14. $world = World::find($id);
  15. $world->randomNumber = $randomNumber;
  16. $world->save();
  17. $arr[] = $world->toArray();
  18. }
  19. // Use the PHP standard JSON encoder.
  20. // http://www.php.net/manual/en/function.json-encode.php
  21. header('Content-Type: application/json');
  22. echo json_encode($arr);