Skip to content

Commit ce5f823

Browse files
authored
Update benchmark.php
1 parent 40d2833 commit ce5f823

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

benchmark.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
public function __construct($dbname, $host, $username, $password = '')
1717
{
1818
$this->db = new PDO('mysql:dbname=' . $dbname . ';host=' . $host, $username, $password);
19+
$this->checkAndCreateTables();
1920
}
2021

2122
public function insertBenchmark($time = 5000)
@@ -82,6 +83,19 @@ public function drawBenchmark()
8283
}
8384
}
8485

86+
private function checkAndCreateTables()
87+
{
88+
$sql = 'CREATE TABLE IF NOT EXISTS `members` (
89+
`id` int(11) NOT NULL AUTO_INCREMENT,
90+
`name` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
91+
`number` int(11) NOT NULL,
92+
`gb` int(11) NOT NULL,
93+
PRIMARY KEY (`id`)
94+
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci';
95+
96+
$this->db->query($sql);
97+
}
98+
8599
private function setCounter($counter)
86100
{
87101
$this->counter = $counter;

0 commit comments

Comments
 (0)