PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I was wondering what would be the best way to connect to two database's in the same script. I want to go for the OO approach for many reasons, which I wont go into here (since I have seen the effects it can cause )
I had a quick browse of the PHP manual for seeing if you could add something to the mysql_query function to determine which database you wanted to get info from, but I couldn't find anything.
Anyone know if this is possible, and if so, how I would go about it?
mysql_query() sends a query (to the currently active database on the server that's associated with the specified link_identifier).
query
A SQL query
The query string should not end with a semicolon.
link_identifier
The MySQL connection. If the link identifier is not specified, the last link opened by mysql_connect() is assumed. If no such link is found, it will try to create one as if mysql_connect() was called with no arguments. If by chance no connection is found or established, an E_WARNING level warning is generated.
The link identifier parameter can be used to specify an open database connection.
-> connection is the variable that contains the connection info.
I am used to JAVA, so I assume that PHP OO works in the same way, in which each new instance contains a fresh set of variables for the instance to work with?
let's see how you created the connection, without seeing into your class I can't tell much, but that looks like it should be working unless you are not storing the link identifier within your class correctly