|
@@ -10,11 +10,20 @@ Class Controller_Bench extends Controller
|
|
}
|
|
}
|
|
|
|
|
|
public function action_db()
|
|
public function action_db()
|
|
|
|
+ {
|
|
|
|
+ $query = DB::query(Database::SELECT, 'SELECT * FROM World WHERE id = :id')->bind(':id', $id);
|
|
|
|
+
|
|
|
|
+ $world = $query->param(':id', mt_rand(1, 10000))->execute()->current();
|
|
|
|
+
|
|
|
|
+ $this->response
|
|
|
|
+ ->headers(array('Content-Type' => 'application/json'))
|
|
|
|
+ ->body(json_encode($world));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function action_queries()
|
|
{
|
|
{
|
|
$queries = $this->request->param('queries', false);
|
|
$queries = $this->request->param('queries', false);
|
|
- $queries = $queries
|
|
|
|
- ? $queries
|
|
|
|
- : 1;
|
|
|
|
|
|
+ $queries = is_numeric($queries) ? min(max($queries, 1), 500) : 1;
|
|
|
|
|
|
$worlds = array();
|
|
$worlds = array();
|
|
|
|
|
|
@@ -24,10 +33,6 @@ Class Controller_Bench extends Controller
|
|
$worlds[] = $query->param(':id', mt_rand(1, 10000))->execute()->current();
|
|
$worlds[] = $query->param(':id', mt_rand(1, 10000))->execute()->current();
|
|
}
|
|
}
|
|
|
|
|
|
- if ($queries == 1) {
|
|
|
|
- $worlds = $worlds[0];
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
$this->response
|
|
$this->response
|
|
->headers(array('Content-Type' => 'application/json'))
|
|
->headers(array('Content-Type' => 'application/json'))
|
|
->body(json_encode($worlds));
|
|
->body(json_encode($worlds));
|