13 Star 81 Fork 13

谭家俊 / MysqlPool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CoroutineMySql.php 604 Bytes
一键复制 编辑 原始数据 按行查看 历史
tan_jia_jun 提交于 2018-09-11 20:42 . 数据库连接池
<?php
/**
* 协程Mysql客户端Demo
* @author tanjiajun
*/
go(function () {
$start = microtime(true);
$db = new Swoole\Coroutine\MySQL();
$db->connect([
'host' => '10.0.2.2',
'port' => 3306,
'user' => 'root',
'password' => 'root',
'database' => 'test',
'timeout' => 6#1
]);
$db->query("select sleep(5)");
echo "我是第一个sleep五秒之后\n";
$ret = $db->query("select user from guestbook limit 1");#2
var_dump($ret);
$use = microtime(true) - $start;
echo "协程mysql输出用时:" . $use . PHP_EOL;
});
PHP
1
https://gitee.com/tanjiajun/MysqlPool.git
git@gitee.com:tanjiajun/MysqlPool.git
tanjiajun
MysqlPool
MysqlPool
master

搜索帮助