[prog] MySQL connections from PHP files - Close or keep it open for
queries?
Gareth Anderson
somecsstudent at gmail.com
Sun May 1 22:39:05 EST 2005
Hi everyone,
I'm a student (3rd year computer science) working on a project.
The aim of this project is to create a mailing list software in PHP
and mySQL which will be used by a not-for-profit organisation.
Anyway, the majority of the project does a number of mySQL queries in
the individual PHP page.
mysql_connect(...)
Then mysql query
PHP code
mysql query
PHP code
mysql query
mysql_close()
However, there is another way this could be done, I could also do a
connection/disconnect for each individual query.
Ie.
mysql_connect(...)
Then mysql query
mysql_close()
PHP code
mysql_connect(...)
mysql query
mysql_close()
Which way is preferred?
The PHP files are doing a little processing, mostly text based so they
should run incredibly fast. However is it perferred to keep an open
connection to the database with multiple queries?
Or to have an individual connection/disconnection with each query?
Regards,
Gareth
Note: the way I do this does not effect my marks for the subject. The
lecturer is not very familiar with PHP/mySQL, thats why we're doing an
"individual project".
So in other words I'm looking for general comments on this.
More information about the Programming
mailing list