Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $host = '127.0.0.1';
- $db = 'cns';
- $user = 'root';
- $pass = 'password';
- $charset = 'utf8mb4';
- $dsn = "mysql:host=$host;dbname=$db;charset=$charset";
- $options = [
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
- PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
- PDO::ATTR_EMULATE_PREPARES => false,
- ];
- try {
- $pdo = new PDO($dsn, $user, $pass, $options);
- $start = microtime(true);
- for ($t = 1; $t <= 150; $t++) {
- echo $t.PHP_EOL;
- $stmt = $pdo->query('select * from history_datas where coins_id = '.$t.' order by created_at desc');
- while ($row = $stmt->fetch())
- {
- //echo "\t".$row['coins_id'].'-'.$row['created_at'] . "\n";
- }
- }
- echo (microtime(true) - $start).PHP_EOL;
- } catch (\PDOException $e) {
- throw new \PDOException($e->getMessage(), (int)$e->getCode());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement