Jump to content

epinc

New Members
  • Posts

    1
  • Joined

  • Last visited

epinc's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. We have a 10 year old system that has 100's of php files that all connect to a central database using a single shared php include file that does a mysql_connect before any other code executes include_once("db_connect.php"); mysql_query(...); We never used the returned connection id (link identifier) from the mysql_connect function call as it was always implied in every subsequent mysql_query statement etc. Now we've moved some of our bigger tables to a separate server, so we have to update small areas of some files that need to connect to this other system and send the old existing query to the new server instead of to the main server and process the results So, going back through hundreds of files and converting mysql_query($string) to mysql_query($string, $connection1) is not practical Possible solution one: anytime I need to use the new server I do this ------------------------------------------------------------------------------ mysql_connect(NEW_SERVER_IP,"...","""); mysql_query($string); ... // get back to normal mysql_connect(OLD_SERVER_IP,"...",""); Possible solution two: modify the master include file ------------------------------------------------------------------------------ //add a new line ABOVE the existing mysql_connect statement... $new_server=mysql_connect(NEW_SERVER_IP,"...","""); mysql_connect(OLD_SERVER_IP,"...",""); and then anytime I need to use the new database I have to go back and modify all of the mysql_query,mysql_affected_rows, etc to reference the $new_server link identifier solution one seems much simpler, but all of the mysql_connect reconnections I assume will be extremely inefficient solution two seems cleaner but if I miss one mysql_ statement that needs the new connection object as a reference, the code will completely break or worse yet it will produce unexpected results Example: If I miss converting a mysql_errno() function that really needs to now be mysql_errno($new_server) it would cause major issues. So, I'm wondering if others have faced this dilema of migrating single mysql_connect code to multi mysql_connect mode and if there is a better way of going about implementing it. Thanks in advance for any help Steve
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.