Connect to Different Database Depending on MySQL Syntax
On a typical page I will have a number of queries that all refer to the same mysql resource...
Both an Update and a Select at least. I'm going to use two remote MySQL servers now, one for everything other than Select (a master DB to write to), and the other for Select queries only.
Here is my typicaly mysql_connect script resource referred to by all my MySQL queries:
Instead of changing the queries to a new connection resource other than $dbh, is there some way I can have my connection script recognize the mysql syntax being called, and pick the proper mysql server based on that? So, if the query is an UPDATE, I'd want it to connect to server2_address/db2 instead of shown above.
$dbh=mysql_connect ("server1_address", "user", "password") or
die ('I cannot connect to the database because: ' . mysql_error());
At all possible? I have about 100 static pages that run my site, and each has up to 10 mysql queries. I'm trying to avoid having to change every query that is not using SELECT syntax to use secondary db connection resource.
Any feedback appreciated.