fbf/mysql-reconnect
Composer 安装命令:
composer require fbf/mysql-reconnect
包简介
A PDO wrapper that reconnects automatically and re-issues queries on receiving MySQL server timeout errors
README 文档
README
A PDO wrapper that reconnects automatically and re-issues queries on receiving MySQL server timeout errors
Usage
$config = array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'mydb',
'user' => 'username',
'pass' => 'password',
);
$db = new Fbf\MysqlReconnect\Db($config);
$sql = "SELECT * FROM posts WHERE id = :id";
$data = array('id' => 1);
$sth = $db->query($sql, $data);
$post = $sth->fetchObj();
How it works
Uses __call() magic method to pass off methods called to the PDO connection object, so you can call whatever you like on $db and it will pass it off to PDO. Inside the magic method we catch timeout exceptions and then reconnect before re-issuing the query.
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-10-14