Page 1 of 1

Are there any drawbacks to having multiple db connections?

Posted: Mon May 22, 2017 6:12 pm
by thinsoldier
I'm very slowly updating a legacy project to be php7 compliant.

There are many raw mysql_query calls, and functions that contain mysql_query, and primative poorly written models that use both.

I want to switch to either raw PDO or something like https://github.com/colshrapnel/safemysql or a stand-alone version of Laravel's Eloquent but I won't be able to update every part of the project all at once. This means most views will do both the original mysql_connect and the connection for the new library.

Are there any drawbacks or problems that arise from making 2 db connections in the same script?

Re: Are there any drawbacks to having multiple db connection

Posted: Tue May 23, 2017 2:08 am
by requinix
Well, it will double the number of connections open to your database, meaning you'll exhaust that resource twice as fast. Some things like transactions and temporary tables don't work across connections.

Don't rush the upgrade. Do it as you can, test, and release when it's ready.