forked from whcyc2002/swoole_framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasync_mysql.php
More file actions
41 lines (38 loc) · 1.08 KB
/
Copy pathasync_mysql.php
File metadata and controls
41 lines (38 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
define('DEBUG', 'on');
define('WEBPATH', realpath(__DIR__ . '/..'));
//包含框架入口文件
require WEBPATH . '/libs/lib_config.php';
$config = array(
'host' => '127.0.0.1',
'user' => 'root',
'password' => 'root',
'database' => 'test',
);
$pool = new Swoole\Async\MySQL($config, 10);
$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 < 2000; $i++)
{
$pool->query($sql3, function (mysqli $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";
sleep(1);
}
else
{
//var_dump($result);
}
echo "$i\t" . str_repeat('-', 120) . "\n";
usleep(100000);
});
}