|
@@ -40,44 +40,45 @@ class TestController extends Controller
|
|
|
public function DB()
|
|
|
{
|
|
|
require_once("Model/World.php");
|
|
|
-
|
|
|
- $id = mt_rand(1, 10000);
|
|
|
- $world = $this->Phreezer->Get("World",$id);
|
|
|
+
|
|
|
+ $id = mt_rand(1, 10000);
|
|
|
+ $world = $this->Phreezer->Get("World",$id);
|
|
|
$this->RenderJSON($world,'',true);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /**
|
|
|
- * Test route that connects to the database and outputs
|
|
|
- * the number of rows specified in the querystring argument "queries"
|
|
|
- */
|
|
|
- public function Query()
|
|
|
- {
|
|
|
- require_once("Model/World.php");
|
|
|
-
|
|
|
- // Read number of queries to run from URL parameter
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Test route that connects to the database and outputs
|
|
|
+ * the number of rows specified in the querystring argument "queries"
|
|
|
+ */
|
|
|
+ public function Query()
|
|
|
+ {
|
|
|
+ require_once("Model/World.php");
|
|
|
+
|
|
|
+ // Read number of queries to run from URL parameter
|
|
|
$query_count = RequestUtil::Get('queries',1);
|
|
|
-
|
|
|
- // make sure the query count paramter is in range
|
|
|
+ $query_count = is_numeric($query_count) ? min(max($query_count, 1), 500) : 1;
|
|
|
+
|
|
|
+ // make sure the query count paramter is in range
|
|
|
if (!is_numeric($query_count)) {
|
|
|
$query_count = 1;
|
|
|
}
|
|
|
else {
|
|
|
$query_count = max(1,min($query_count,500));
|
|
|
}
|
|
|
-
|
|
|
- $arr = array();
|
|
|
-
|
|
|
- for ($i = 0; $i < $query_count; $i++) {
|
|
|
-
|
|
|
- $id = mt_rand(1, 10000);
|
|
|
+
|
|
|
+ $arr = array();
|
|
|
+
|
|
|
+ for ($i = 0; $i < $query_count; $i++) {
|
|
|
+
|
|
|
+ $id = mt_rand(1, 10000);
|
|
|
|
|
|
- // convert the Phreezable object into a simple structure for output
|
|
|
- $arr[] = $this->Phreezer->Get("World",$id)->ToObject();
|
|
|
- }
|
|
|
-
|
|
|
- $this->RenderJSON($arr);
|
|
|
-
|
|
|
+ // convert the Phreezable object into a simple structure for output
|
|
|
+ $arr[] = $this->Phreezer->Get("World",$id)->ToObject();
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->RenderJSON($arr);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -104,47 +105,48 @@ class TestController extends Controller
|
|
|
Phreezer::Sort($fortunes);
|
|
|
|
|
|
// Render using a template
|
|
|
- $this->RenderEngine = new PHPRenderEngine('templates');
|
|
|
+ $this->RenderEngine = new PHPRenderEngine('templates');
|
|
|
$this->Assign('fortunes',$fortunes);
|
|
|
$this->Render('TestFortunes.php');
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Test for performing updates
|
|
|
- */
|
|
|
- public function Updates()
|
|
|
+ /**
|
|
|
+ * Test for performing updates
|
|
|
+ */
|
|
|
+ public function Updates()
|
|
|
{
|
|
|
- require_once("Model/World.php");
|
|
|
-
|
|
|
- // Read number of queries to run from URL parameter
|
|
|
- $query_count = RequestUtil::Get('queries',1);
|
|
|
-
|
|
|
- $arr = array();
|
|
|
-
|
|
|
- for ($i = 0; $i < $query_count; $i++) {
|
|
|
-
|
|
|
- $id = mt_rand(1, 10000);
|
|
|
-
|
|
|
+ require_once("Model/World.php");
|
|
|
+
|
|
|
+ // Read number of queries to run from URL parameter
|
|
|
+ $query_count = RequestUtil::Get('queries',1);
|
|
|
+ $query_count = is_numeric($query_count) ? min(max($query_count, 1), 500) : 1;
|
|
|
+
|
|
|
+ $arr = array();
|
|
|
+
|
|
|
+ for ($i = 0; $i < $query_count; $i++) {
|
|
|
+
|
|
|
+ $id = mt_rand(1, 10000);
|
|
|
+
|
|
|
$world = $this->Phreezer->Get("World",$id);
|
|
|
|
|
|
// update the random number and persist the record
|
|
|
$world->Randomnumber = mt_rand(1, 10000);
|
|
|
- $world->Save();
|
|
|
-
|
|
|
- // convert the Phreezable object into a simple structure for output
|
|
|
- $arr[] = array('id'=>$world->Id,'randomNumber'=>$world->Randomnumber);
|
|
|
- }
|
|
|
-
|
|
|
- $this->RenderJSON($arr);
|
|
|
+ $world->Save();
|
|
|
+
|
|
|
+ // convert the Phreezable object into a simple structure for output
|
|
|
+ $arr[] = array('id'=>$world->Id,'randomNumber'=>$world->Randomnumber);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->RenderJSON($arr);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Test for outputting plaintext
|
|
|
- */
|
|
|
- public function PlainText()
|
|
|
+ /**
|
|
|
+ * Test for outputting plaintext
|
|
|
+ */
|
|
|
+ public function PlainText()
|
|
|
{
|
|
|
header('Content-type: text/plain');
|
|
|
- echo 'Hello, World!';
|
|
|
+ echo 'Hello, World!';
|
|
|
}
|
|
|
|
|
|
}
|