TestController.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /** @package HELLO WORLD::Controller */
  3. /** import supporting libraries */
  4. require_once("verysimple/Phreeze/Controller.php");
  5. /**
  6. *
  7. * @package HELLO WORLD::Controller
  8. * @author ClassBuilder
  9. * @version 1.0
  10. */
  11. class TestController extends Controller
  12. {
  13. /**
  14. * Not used but necessary to implement Controller
  15. * @see Controller::Init()
  16. */
  17. protected function Init()
  18. {
  19. }
  20. /**
  21. * Test route that outputs a simple JSON object
  22. */
  23. public function JSON()
  24. {
  25. $arr = array(
  26. "message" => "Hello, World!"
  27. );
  28. $this->RenderJSON($arr);
  29. }
  30. /**
  31. * Test route that connects to the database and outputs
  32. * the number of rows specified in the querystring argument "queries"
  33. */
  34. public function DB()
  35. {
  36. // Read number of queries to run from URL parameter
  37. $query_count = RequestUtil::Get('queries',1);
  38. $arr = array();
  39. for ($i = 0; $i < $query_count; $i++) {
  40. $id = mt_rand(1, 10000);
  41. $world = $this->Phreezer->Get("World",$id);
  42. // convert the Phreezable object into a simple structure for output
  43. $arr[] = array('id'=>$world->Id,'randomNumber'=>$world->Randomnumber);
  44. }
  45. $this->RenderJSON($arr);
  46. }
  47. }