News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

mysql_connect doubts

Started by DMoushe, April 07, 2007, 10:49:05 AM

Previous topic - Next topic

DMoushe

Well, these questions don't contain code, but I thought this is where they should go.

1- I've been creating a site these days, and whenever I want to access some data on the DB I use the db_query function that comes with SMF. But I've been wondering... would it be ok if in a script I created a connection to the database with mysql_connect? I've read on the forums that db_query doesn't use a mysql connection to access the data, so it specifies the db name in the query itself. Would I break something if I created a link to the database?

2- The description for the mysql_connect funcion (http://cl.php.net/manual/en/function.mysql-connect.php [nofollow]) says that if a connection has already been created with the same parameters as the one I'm trying to create now, it will reuse that connection. Now, if different users are working on different scripts, and both scripts create a connection to the DB with the same parameters to make different queries to the DB, won't these queries affect each other? What if they are inserting some values to row with an auto-increment column, and then they ask for mysql_insert_id... what would happen? would one of them get an incorrect result?

Sorry for my bad english, I hope my questions were clear enough. Thanks for any help you can provide :)

Advertisement: