|
Posted by Gordon Burditt on 06/26/05 20:54
>How can I make a database connection available to all the pages in my
>application?
>I tried doing it with session but it doesn't seem to work.
You can't store database connections in sessions.
The closest you can come is to use a persistent connection, which
still requires that you call mysql_pconnect in every page which
might use the connection (although putting that code in an include
file is a possibility). After all, PHP needs the connection info
in case you are the first one to need it after the server restarts.
One disadvantage of persistent connections is that if you have
M different sets of server/login/password connection info, and
a max of N Apache processes, you may accumulate M*N persistent
connections, and the database has to be able to handle that many,
even if most of them are idle at any given time.
Gordon L. Burditt
Navigation:
[Reply to this message]
|