|
@@ -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]
|
|
|
);
|