[Tutor] MySQL api does not accept variable.
Alan Gauld
alan.gauld at freenet.co.uk
Fri Jan 6 16:18:44 CET 2006
> I can't think of the con's and the pro's of keeping open
> the mysql connection when the script starts and close
> it when it ends..
The reasoning is that you want to open the connection at
the start of a script do all your processing then close it.
In between you might want to add data, create new tables,
select data and other thoings, including getting a list of users.
Now with your code you would need to close the connection
before calling your function then reopen it again to fiunish
off the rest of the work. Its OK if your function is only ever
used in a single script and is the only access to the database,
but if you ever want to get the users in any other program
your function is almost unusably inconvenient.
> computers (I run this script at a p4 2.6 Ghz 512 RAM with a lot free
> memory) I don't think that there will be any real difference.
You are quite correct for a single user on a modern PC. But...
It would make a difference in a high volume environment with
many users (like a web application say), or on an older machine
but the real value is when you want to use the function as part
of a bigger program that has already opened the connection
to the database.
Regards,
Alan G.
More information about the Tutor
mailing list