Download the PHP package adgoal/dbal-fault-tolerance without Composer
On this page you can find all versions of the php package adgoal/dbal-fault-tolerance. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download adgoal/dbal-fault-tolerance
More information about adgoal/dbal-fault-tolerance
Files in adgoal/dbal-fault-tolerance
Package dbal-fault-tolerance
Short Description Auto reconnect on Doctrine MySql has gone away exceptions on doctrine/dbal
License Apache-2.0
Informations about the package dbal-fault-tolerance
DBALFaultTolerance
Auto reconnect on Doctrine MySql has gone away exceptions on doctrine/dbal >=2.3, <3.0.
Installation
Configuration
In order to use DBALFaultTolerance you have to set wrapperClass
and driverClass
connection params.
You can choose how many times Doctrine should be able to reconnect, setting x_reconnect_attempts
driver option. Its value should be an int.
You can force ignore the transaction level using the parameters : force_ignore_transaction_level
.
An example of configuration at connection instantiation time:
An example of yaml configuration on Symfony 2 projects:
An example of configuration on Zend Framework 2/3 projects:
You can use wrapper class Adgoal\DBALFaultTolerance\Connections\MasterSlaveConnection
if you are
using master / slave Doctrine configuration.
Usage
To force a reconnection try after a long running task you can call
before performing any other operation different from SELECT.
Instead, in case your next query will be a SELECT, reconnection will be automagically done.
From v1.6
automagically reconnection is enabled also during $em->getConnection()->beginTransaction()
calls,
and this works also during simple $em->flush()
, if out of a previous transaction.
Thanks
Thanks to Dieter Peeters and his proposal on DBAL-275. Check it out if you are using doctrine/dbal <2.3.