Skip to content

Commit b1604b3

Browse files
committed
Add PHP 5.5 benchmark
1 parent 09b73d6 commit b1604b3

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

crud.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
$host = '127.0.0.1';
3+
$user = 'root';
4+
$password = null;
5+
$database = 'php-benchmarks';
6+
7+
function error_500($message)
8+
{
9+
header('HTTP/1.1 500 Internal Server Error');
10+
exit($message);
11+
}
12+
13+
function show_mysqli_error(mysqli $mysqli, $line)
14+
{
15+
if ($mysqli->error) {
16+
error_500('[' . $line . '] ' . $mysqli->error);
17+
}
18+
}
19+
20+
$mysqli = new mysqli($host, $user, $password, $database);
21+
if ($mysqli->connect_error) {
22+
error_500($mysqli->connect_error);
23+
}
24+
25+
// create
26+
$mysqli->query("
27+
INSERT INTO bench_crud (firstName, lastName, email, message)
28+
VALUES ('Steevan', 'BARBOYON', 'steevan.barboyon@gmail.com', 'php-benchmarks, the first php benchmarks site !')
29+
");
30+
show_mysqli_error($mysqli, __LINE__);
31+
$id = $mysqli->insert_id;
32+
33+
// read
34+
$mysqli->query('SELECT * FROM bench_crud WHERE id = ' . $id);
35+
show_mysqli_error($mysqli, __LINE__);
36+
37+
// update
38+
$mysqli->query("
39+
UPDATE bench_crud
40+
SET firstName = 'InfoDroid', lastName = 'InfoDroid', email = 'contact@info-droid.fr', message = 'php-benchmarks, the ultimate php benchmarks site !'
41+
WHERE id = " . $id
42+
);
43+
show_mysqli_error($mysqli, __LINE__);
44+
45+
// delete
46+
$mysqli->query('DELETE FROM bench_crud WHERE id = ' . $id);
47+
show_mysqli_error($mysqli, __LINE__);
48+
49+
$mysqli->close();

helloworld.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
echo 'Hello World !';

0 commit comments

Comments
 (0)