コード例 #1
0
ファイル: big.php プロジェクト: cjq/mysql-async
<?php

require __DIR__ . '/../Swoole/Async/MySQL.php';
$config = array('host' => '172.19.104.157', 'user' => 'root', 'password' => 'root', 'database' => 'db_live', 'charset' => 'utf8');
$pool = new Swoole\Async\MySQL($config, 100);
for ($i = 0; $i < 10000; $i++) {
    $pool->query("SELECT * FROM `access_log` WHERE id = 496", function ($mysqli, mysqli_result $result) {
        echo count($result->fetch_all());
        //var_dump($result->fetch_all());
    });
}
コード例 #2
0
ファイル: run.php プロジェクト: cjq/mysql-async
<?php

require __DIR__ . '/../Swoole/Async/MySQL.php';
$config = array('host' => '127.0.0.1', 'user' => 'root', 'password' => 'root', 'database' => 'test');
$pool = new Swoole\Async\MySQL($config, 100);
for ($i = 0; $i < 10000; $i++) {
    $pool->query("show tables", function ($mysqli, mysqli_result $result) {
        var_dump($result->fetch_all());
    });
}
コード例 #3
0
ファイル: test.php プロジェクト: silentred/learning-path
<?php

include "MySQL.php";
$config = array('host' => '172.16.1.19', 'database' => '1188test', 'user' => 'test', 'password' => 'test');
$client = new Swoole\Async\MySQL($config);
$start = microtime();
for ($i = 1; $i < 5000; $i += 1) {
    $result = $client->query("select * from video LIMIT {$i}, 10;", function ($mysqli, $result) use($i, $start) {
        $result->fetch_all();
        if ($i == 4999) {
            $end = microtime();
            echo "used time : " . ($end - $start);
        }
    });
}
/*
运行到这里脚本没有退出,不知道原因
*/
コード例 #4
0
<?php

define('DEBUG', 'on');
define('WEBPATH', realpath(__DIR__ . '/..'));
//包含框架入口文件
require WEBPATH . '/libs/lib_config.php';
$config = array('host' => '10.10.2.38', 'user' => 'root', 'password' => 'root', 'database' => 'chelun');
$pool = new Swoole\Async\MySQL($config, 20);
//$sql1 = "INSERT INTO `test`.`userinfo`
// (`id`, `name`, `passwd`, `regtime`, `lastlogin_ip`)
// VALUES ('0', 'womensss', 'world', '2015-06-15 13:50:34', '4')";
//$sql2 = "update userinfo set name='rango' where id = 16";
$sql3 = "show tables";
for ($i = 0; $i < 200; $i++) {
    $pool->query($sql3, function (swoole_mysql $mysqli, $result) use($i) {
        if ($result === true) {
            echo "insert_id={$mysqli->insert_id}, _affected_rows={$mysqli->affected_rows}\n";
        } elseif ($result === false) {
            echo "errno={$mysqli->errno}, error={$mysqli->error}\n";
        } else {
            //var_dump($result);
        }
        echo "{$i}\t" . str_repeat('-', 120) . "\n";
        //usleep(10000);
    });
}