Browse Source

Clean php-ngx code (#6106)

Joan Miquel 4 years ago
parent
commit
51a4e2bdbc
1 changed files with 3 additions and 4 deletions
  1. 3 4
      frameworks/PHP/php-ngx/app.php

+ 3 - 4
frameworks/PHP/php-ngx/app.php

@@ -7,7 +7,6 @@ $pdo = new PDO('mysql:host=tfb-database;dbname=hello_world', 'benchmarkdbuser',
 
 $statement = $pdo->prepare('SELECT id,randomNumber FROM World WHERE id=?');
 $fortune   = $pdo->prepare('SELECT id,message FROM Fortune');
-$random    = $pdo->prepare('SELECT id,randomNumber FROM World WHERE id=?');
 $update    = $pdo->prepare('UPDATE World SET randomNumber=? WHERE id=?');
 
 function db()
@@ -39,7 +38,7 @@ function query()
 
 function update()
 {
-    global $random, $update;
+    global $statement, $update;
     ngx_header_set('Content-Type', 'application/json');
 
     $query_count = 1;
@@ -49,9 +48,9 @@ function update()
     }
     while ($query_count--) {
         $id = mt_rand(1, 10000);
-        $random->execute([$id]);
+        $statement->execute([$id]);
 
-        $world = ['id' => $id, 'randomNumber' => $random->fetchColumn()];
+        $world = $statement->fetch();
         $update->execute(
             [$world['randomNumber'] = mt_rand(1, 10000), $id]
         );