News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Lorna Mitchell's Blog:
Dealing with MySQL Gone Away in Zend Framework
March 01, 2011 @ 10:03:01

Lorna Mitchell has a (very) quick tip for those using the Zend Framework with a MySQL database. Sometimes the inevitable "MySQL server has gone away" error will pop up - her tip shows you how to deal with it correctly in a long-running application.

The [Gearman] worker is a Zend Framework application, run from the CLI, and it seemed like the Zend_Db_Adapter had no way of knowing when MySQL had let go of its end of the connection. I tried a few different things, including Zend_Db_Adapter::getConnection(), but without success - until I dug through the source code (with some help from a friend) and realised that ZF was not reconnecting at all if it thought it already had a connection.

She ended up putting a connection into a registry and, when the process was done, forcing the connection to close. This made the next worker in the queue forcefully open another new connection rather than having the same one pending for (possibly) days at a time.

0 comments voice your opinion now!
mysql goneaway error zendframework gearman


blog comments powered by Disqus

Similar Posts

Artur Ejsmont's Blog: How to structure a Zend Framework application and it's dependencies

Zend Developer Zone: The ZendCon Sessions Episode 9: QEDWiki and Zend Framework

DevShed: Generating View from MySQL to Simulate the Model-View-Controller Schema in PHP

Zend Developer Zone: The Storage Medium

Pádraic Brady's Blog: Complex Views with the Zend Framework - Part 7: Zend_View Enhanced


Community Events





Don't see your event here?
Let us know!


code release podcast list api install refactor laravel community testing series developer opinion language threedevsandamaybe framework wordpress introduction unittest interview

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework