Commit cc2fd64f authored by Alan Farquharson's avatar Alan Farquharson
Browse files

Initial commit

parents
<?php
$host = '127.0.0.1';
$db = 'test';
$user = 'root';
$pass = '';
$charset = 'utf8mb4';
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$opt = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
$pdo = new PDO($dsn, $user, $pass, $opt);
$current = new DateTime();
$end = new DateTime('+1 minute');
$count = 0;
while ($current < $end) {
$query = 'SELECT * FROM `example` WHERE id = ? and `name` = ?';
$stmt = $pdo->prepare($query);
$args = [1 => 1, 2 => 'Alan'];
$stmt->execute($args);
$fetched = $stmt->fetch();
$count++;
$current = new DateTime();
}
echo 'I managed to do ' . number_format($count) . ' queries in 60 seconds' . PHP_EOL;
<?php
$host = '127.0.0.1';
$db = 'test';
$user = 'root';
$pass = '';
$charset = 'utf8mb4';
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$opt = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
$pdo = new PDO($dsn, $user, $pass, $opt);
$current = new DateTime();
$end = new DateTime('+1 minute');
$count = 0;
while ($current < $end) {
$query = 'SELECT * FROM `example` WHERE id = ? and `name` = ?';
$stmt = $pdo->prepare($query);
$stmt->execute([1 => 1, 2 => 'Alan']);
$fetched = $stmt->fetch();
$count++;
$current = new DateTime();
}
echo 'I managed to do ' . number_format($count) . ' queries in 60 seconds' . PHP_EOL;
<?php
$host = '127.0.0.1';
$db = 'test';
$user = 'root';
$pass = '';
$charset = 'utf8mb4';
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$opt = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
$pdo = new PDO($dsn, $user, $pass, $opt);
$current = new DateTime();
$end = new DateTime('+1 minute');
$count = 0;
while ($current < $end) {
$query = 'SELECT * FROM `example` WHERE id = :id and `name` = :name';
$stmt = $pdo->prepare($query);
$stmt->execute(['id' => 1, 'name' => 'Alan']);
$fetched = $stmt->fetch();
$count++;
$current = new DateTime();
}
echo 'I managed to do ' . number_format($count) . ' queries in 60 seconds' . PHP_EOL;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment