Taylor Otwell Mon Jan 24 11:31:45 -0500 2011

Subject: Change connections in middle of Script?

When I initialize PHP ActiveRecord, I set the default connection. Is there a way to totally change connections in the middle of my script so that all my models will then be using the new connection?


Kien La Fri Feb 04 17:55:48 -0500 2011

Are you trying to have it reconnect to the same database or a different one?

Taylor Otwell Fri Feb 04 17:56:36 -0500 2011

Totally different one.

Kien La Sun Feb 06 12:10:45 -0500 2011

You might be able to just call your initialization block with the new connection settings. I haven't tested this but I think it should work. Let me know if it does or not if you do try this.

Kien La Sun Feb 06 12:12:50 -0500 2011

Actually no, I think that won't work. I'll take a look at this today and see what I can do.

Kien La Sun Feb 06 22:07:14 -0500 2011

Try this: