Question:
mySQL: multilingal system db access and concurrent querries?
?
2008-10-24 10:48:48 UTC
In a system, we have a DB table that contains languages strings. This table is opened and selected on entry in the site.
In the meantime, during the session, many calls are made to the same DB (but different tables).
Q: what is the most EFFICIENT way?
1- open the db at the beginning of the session and close it at the end
2- open the db with a global "link" value for the strings, and use another dbopen link for every "in-the-session" calls?
Which of these options is "the most efficient" ?
(I used o open/close EVERY call to DB).
Would open once, close once would be more efficient?
Would that not allow for security risks?
Three answers:
PhpMyCoder
2008-10-24 10:55:57 UTC
Well, security risks are not affected by how long a DB is open. I usually use your first method and use a variable such as $con to store the MySQL connection. When needed I simply call the MySQL function and add the $con variable. Opening and closing the connection every time you make a call will put a severe load on the server. Just one connection will do, just make sure you disconnect when you are done!!
Tim C
2008-10-24 11:14:36 UTC
I would open the database once when the page loads, and close it at the bottom. I would not try and leave the connection open throughout the session.

I'm not even sure if you can do that. I'm pretty sure that if your script ends without closing the connection, your connection will be closed automatically.



By session, do you mean like a single login session?

http://en.wikipedia.org/wiki/Session_management#Web_server_session_management

You really, really don't want to keep a connection open to MySQL during idle time (waiting for the user to do something else). not at all.
2016-10-19 10:57:27 UTC
because of the fact the database is in basic terms used for usernames and passwords, get right of entry to could paintings in basic terms high quality (except you have hundreds of hundreds of clients). authentic, get right of entry to has its barriers even yet it truly is probably sufficient on your purposes. You look soft with get right of entry to, so why not use it? you may continuously swap to a minimum of something else later, if mandatory. ยง


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...