Try this patch http://github.com/kla/php-activerecord/commit/aed05c2ac86457bafb41c386072701e8e9228b9e
Let me know if that works or not.
Oh so close.... From what I can tell, it reconnects to the server and hooks that up to the model where called... for example, YouModel::reestablish_connection() will make queries attached to YourModel work, however, any associations still appear to throw the "server has gone away" exception from Connection.php on line 276...
Thanks you so much for working on this. php-activerecord is a great ORM
Add a call to clear_cache() in reestablish_connection like so:
public function reestablish_connection($close=true) { // if connection name property is null the connection manager will use the default connection $connection = $this->class->getStaticPropertyValue('connection',null); if ($close) ConnectionManager::drop_connection($connection); static::clear_cache(); return ($this->conn = ConnectionManager::get_connection($connection)); }
Hello,
There is another occasion - connection lost in Connection::query().
How do we access Model or Table instance to call reestablish_connection() here?
(1-4/4)
Subject: reconnecting to lost server connection
Just wondering if there was a way to re-establish a database server connection in the event that it is lost. Working on some daemon processes and I need to able to keep them up and running. I am able to catch and identify the appropriate exception, however, can not find any documentation that would lead me to believe there is anyway to reconnect...
Any suggestions are greatly appreciated.
thanks.