John L. Singleton wrote:
> Speaking of answering questions.... :) I actually have a question
> that's been bugging me and I haven't been able to get a good answer on
> either the forums or the users list.
This is in fact clearly a question for the user mailing-list. And asking
it again on the dev mailing-list is definitely not the way to go. I know
that I am a pain in the ass, but I really want to enforce some basic
rules to help people like me answer more questions.
Nonetheless, let's pretend that we are on the user mailing-list for a
minute and keep reading for a possible answer to your question ;)
>
> This question pertains to MySQL used with Symfony 1.0 and Propel.
>
> I have a LONG running batch script that intermittently needs access to
> MySQL. I begin the script with the lines:
>
> ///code
> $databaseManager = new sfDatabaseManager();
> $databaseManager->initialize();
> code////
>
> And the program goes into an event loop, using FAM as the notifier.
> But, if lots of time elapses between the time I initialize and the
> time I need the connection, I get an error about MySQL has gone away.
> This means that the idle timeout was exceeded for MySQL. I know I
> could just set the timeouts to forever, but that is not a tenable
> solution.
I have the same problem for the task that updates the API documentation
of symfony. It takes ages for phpdocumentor to parse all 4 versions of
the symfony code, and eventually, the database dies before the script ends.
The only solution I found back then was to close and reopen the
connection manually from time to time with the following snippet of code:
Propel::close();
Propel::initialize();
IIRC, there was some cleaner solutions, but they were not doable because
of some methods that were protected/private in Propel code.
But as said by others, using PHP to write a daemon is, well, a scary
proposition ;)
Fabien
>
> The question is: how to I tell Symfony to reconnect to MySQL? Is the
> solution to use something like Propel::getConnection() every time I
> need it? Some other solution? As I mentioned, this script basically
> runs 24/7, only waking up when it needs to do something. As such,
> doing something like upping the MySQL timeout isn't really an option
> for me.
>
> I've tried doing stuff like:
>
> ///code
> $databaseManager = new sfDatabaseManager();
> $databaseManager->initialize();
>
> {do some stuff}
>
> $databaseManager->shutdown();
>
> {wait}
>
> $databaseManager = new sfDatabaseManager();
> $databaseManager->initialize();
> ///code
>
> But that doesn't really work. So I guess the question is, what is the
> best "Symfony" way to do this? I've looked into just grabbing a
> connection from the MySQLConnection class, but that seems to break all
> of the abstraction and sort of defeat the whole purpose of using a
> framework like Symfony in the first place. Could someone please advise?
>
> Best,
> JLS
>
>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---