定制 bushbaby/doctrine-reconnect 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bushbaby/doctrine-reconnect

Composer 安装命令:

composer require bushbaby/doctrine-reconnect

包简介

Zend Framework 2 module which attempts to reconnect when the database has 'gone away'

README 文档

README

Small Zend Framework 2 module which attempts to reconnect when the database has 'gone away'.

Latest Stable Version Total Downloads Latest Unstable Version License

Build Status Code Coverage Scrutinizer Code Quality Dependency Status

In order to do this it overrides Doctrine DBAL Driver provided by the DoctrineORMModule.

I did not invent this method. I just liked it and thought it deserved a zf2 module so it can be reused easily. Credits ought to go to circlical.

Installation

php composer.phar require bushbaby/doctrine-reconnect

Then add BsbDoctrineReconnect to your config/application.config.php.

Adjust your Doctrine DB Config

Copy the config/bsb-doctrine-reconnect.local.php.dist to your config/autoload/config/bsb-doctrine-reconnect.local.php directory and override the specified driverClass for each connection you have have defined.

<?php
return array(
    'doctrine' => array(
        'connection' => array(
            'orm_default' => array(
                'driverClass' => 'BsbDoctrineReconnect\DBAL\Driver\PDOMySql\Driver',
                'wrapperClass' => 'BsbDoctrineReconnect\DBAL\Connection',

                'params' => array(
                    'driverOptions' => array(
                        'x_reconnect_attempts' => 10,
                    ),
                )
            )
        )
    ),
);

Test

You can manually test this actually works by connecting to mysql from the cli and killing the appropriate connection;

mysql> SHOW PROCESSLIST;
+----+------+-----------+----------+---------+------+-------+------------------+
| Id | User | Host      | db       | Command | Time | State | Info             |
+----+------+-----------+----------+---------+------+-------+------------------+
|  1 | root | localhost | database | Sleep   |    1 |       | NULL             |
|  4 | root | localhost | NULL     | Query   |    0 | NULL  | SHOW PROCESSLIST |
+----+------+-----------+----------+---------+------+-------+------------------+
4 rows in set (0.00 sec)

mysql> KILL 1;
Query OK, 0 rows affected (0.00 sec)

Known limitations

This method only works for non transactional statements.

统计信息

  • 总下载量: 4.04k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-01-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固