Reply to Re: how to make a database connection available to all pages?

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация