Re: DB connections ?
| From: | John W. Holmes | Date: | Mon, 05 Jul 2004 18:17:23 +0000 |
| Subject: | Re: DB connections ? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-35129@lists.php.net to get a copy of this message | ||
Michael Gale wrote:
I am designing a web that will require access to a specific database. I am also using sessions and am storing the session data in the database. So on every page that loads there will be a connection to the mysql server (local) to access the session db and tables and the web app database and tables. My question is this would make two db connections per page right ? one after another ? -- which would not be optimized Would it be better to but the session tables in with the web app tables under a common database ?? At first I thought that it would be more secure if the two where separate.So long as you don't close the connection after you get your session data, the next call to mysql_connect() with the same parameters will realize there's already a connection open and use that. Why not have a single include file that connects to your database, though? Then include your custom session hanlder which selects its database and retrieves the data. Then your main script selects it's database and does what it needs to do. Still one connection with less confusion. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com