|
@@ -1,14 +1,12 @@
|
|
<?php
|
|
<?php
|
|
|
|
|
|
-use Workerman\Protocols\Http;
|
|
|
|
-
|
|
|
|
class KuController extends AppController
|
|
class KuController extends AppController
|
|
{
|
|
{
|
|
|
|
|
|
protected function before_filter()
|
|
protected function before_filter()
|
|
{
|
|
{
|
|
View::select(null, null);
|
|
View::select(null, null);
|
|
- Http::header('Content-Type: application/json');
|
|
|
|
|
|
+ header('Content-Type: application/json');
|
|
}
|
|
}
|
|
|
|
|
|
public function index()
|
|
public function index()
|
|
@@ -20,10 +18,11 @@ class KuController extends AppController
|
|
public function query($count = 1)
|
|
public function query($count = 1)
|
|
{
|
|
{
|
|
$count = min(max((int) $count, 1), 500);
|
|
$count = min(max((int) $count, 1), 500);
|
|
|
|
+ $random = KuRaw::$random;
|
|
|
|
|
|
while ($count--) {
|
|
while ($count--) {
|
|
- KuRaw::$random->execute([mt_rand(1, 10000)]);
|
|
|
|
- $worlds[] = KuRaw::$random->fetch();
|
|
|
|
|
|
+ $random->execute([mt_rand(1, 10000)]);
|
|
|
|
+ $worlds[] = $random->fetch();
|
|
}
|
|
}
|
|
echo json_encode($worlds);
|
|
echo json_encode($worlds);
|
|
}
|
|
}
|
|
@@ -31,11 +30,12 @@ class KuController extends AppController
|
|
public function update($count = 1)
|
|
public function update($count = 1)
|
|
{
|
|
{
|
|
$count = min(max((int) $count, 1), 500);
|
|
$count = min(max((int) $count, 1), 500);
|
|
|
|
+ $random = KuRaw::$random;
|
|
|
|
|
|
while ($count--) {
|
|
while ($count--) {
|
|
|
|
|
|
- KuRaw::$random->execute([mt_rand(1, 10000)]);
|
|
|
|
- $row = KuRaw::$random->fetch();
|
|
|
|
|
|
+ $random->execute([mt_rand(1, 10000)]);
|
|
|
|
+ $row = $random->fetch();
|
|
$row['randomNumber'] = mt_rand(1, 10000);
|
|
$row['randomNumber'] = mt_rand(1, 10000);
|
|
|
|
|
|
$worlds[] = $row;
|
|
$worlds[] = $row;
|