Mysql connecting to other database without disconnecting other connection. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Mysql connecting to other database without disconnecting other connection. (
/showthread.php?tid=297599)
Mysql connecting to other database without disconnecting other connection. -
KaleOtter - 16.11.2011
Hello,
When players register on my server I want that there name and password also will be registered on my forum.
But my mysql connection is already connected to my website database.
Can I insert a query into another database (In this case the forum database) without disconnecting the connection with my website database?
Greetz Kaleotter.
Re: Mysql connecting to other database without disconnecting other connection. -
Calgon - 17.11.2011
Depending on the MySQL plugin you use, you can handle multiple connections. The only problem is that you need to specify a connection handle for every query - so the plugin can determine which database you want the query to execute in.
I presume your queries are currently something along the lines of:
pawn Код:
mysql_query("SELECT * FROM `body`");
You'd have to connect to your two databases, create variables for the MySQL connect handle, like:
pawn Код:
new connectionHandle = mysql_connect(...); new connectionHandle2 = mysql_connect(...);
...and update every single query for the correct connection handle, like:
pawn Код:
mysql_query("SELECT * FROM `body`", connectionHandle);
Re: Mysql connecting to other database without disconnecting other connection. -
KaleOtter - 17.11.2011
Ok nice, So if I first connect my database to the website it will be 1?
And when I connect to the forum it will be 2.
So I also can only use the connecthandle with the forum database because i gues that the default connecthandle in a query is 1?
Using BlueG plugin