Db.php 532 B

123456789101112131415161718192021222324
  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. }
  15. public function send() {
  16. headers_sent() OR header('Content-type: application/json');
  17. echo json_encode($this->worlds);
  18. }
  19. }