Db.php 618 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace Controller\Benchmark;
  3. use Model\Benchmark\World;
  4. class Db extends \MyController
  5. {
  6. public function run()
  7. {
  8. $queries = get('queries', 1);
  9. $this->worlds = array();
  10. $this->load_database();
  11. for ($i = 0; $i < $queries; ++$i) {
  12. $this->worlds[] = World::row(array('id' => mt_rand(1, 10000)))->to_array();
  13. }
  14. if ($queries == 1) {
  15. $this->worlds = $this->worlds[0];
  16. }
  17. }
  18. public function send() {
  19. headers_sent() OR header('Content-type: application/json');
  20. echo json_encode($this->worlds);
  21. }
  22. }