BenchController.php 758 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace app\controllers;
  3. use lithium\action\Controller;
  4. use app\models\World;
  5. class BenchController extends Controller {
  6. public function json() {
  7. return $this->render(array(
  8. 'json' => array('message' => 'Hello, World!')
  9. ));
  10. }
  11. public function db() {
  12. $queries = isset($this->request->query['queries'])
  13. ? $this->request->query['queries']
  14. : 1;
  15. $worlds = array();
  16. for ($i = 0; $i < $queries; ++$i) {
  17. $worlds[] = World::first(array(
  18. 'conditions' => array(
  19. 'id' => mt_rand(1, 10000)
  20. )
  21. ));
  22. }
  23. return $this->render(array(
  24. 'json' => $worlds
  25. ));
  26. }
  27. }