FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


SQL: 1 connection or several





tazone
i have a question

on opening a page
which would be faster/better

to connect to the SQL database at the top, do all the queries and disconnect at the bottom
or
for every query connect and disconnect

???
Asap170
This shouldn't go her first of all. It should go here: http://www.frihost.com/forums/vf-14.html

To answer your question I think it would be better to load your MySQL Queries instead of opening and closing it.
tazone
loading it, is that some method i dont know yet?
Asap170
Well I meant like the page being loaded. You do your normal MySQL connection and that. When the page loads it reads what you have so it's just technically loading the code. Hope that helped.
Fire Boar
Asap170, that's a confusing way of putting it.

The answer is that it's most efficient to open the connection when you start, and close it when you're done. Multiple open/close connections are just wasteful.
Lucifer_iix
tazone wrote:
i have a question

on opening a page
which would be faster/better

to connect to the SQL database at the top, do all the queries and disconnect at the bottom
or
for every query connect and disconnect

???



You don't `realy` disconnect at all.

Normaly a database connection is pool-ed.
So, the connection is being reused next time you connect again...

But do you use 1 DB user? Or does every user have a real DB account?

No, i think it doesn't realy matters. But it's always beter to be a good and nice programmer.
Throw every thing away and close if posible... and free your memory....

1 done.... 4 to go...
Related topics
How To : Secure Your PHP Website
Best way to prevent SQL injection attacks
[man] phpBB 2.0.19 (Style Changer/Demo Mod) SQL Injection
A very good PHP MySQL Tutorial
Mysql question!
MySQL HELP!!
PhpNuke Installation Tutorial
How can I create a User account and password for my website?
President defiant at Iran-EU talks
PHP and SQL Server
Problems with SQL
SQL Connection
Multiboot Vista with XP using MBR boot manager
MySql -Connecting problems
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.