You are here: Re: mysql link and session vars « PHP SQL « IT news, forums, messages
Re: mysql link and session vars

Posted by J.O. Aho on 03/21/06 17:30

kees hessels wrote:
> Hi there, How (if) can i store the link from a mysql connect in a session
> variable
> something like
> $_SESSION['db_link']=mysql_connect ( $server, $username, $password );
>
> Currently de mysql link is not saved in the session ...while ather vars are
> properly stored and retrieved ????
> The goal of the exercise is to limit the amount of mysql_connect in my app.

You don't, there aren't any good effects of saving the resource in a session.
mysql_connect() results in a disconnect from the sql server when the
php-script has been run.
mysql_pconnect() tries to keep the connection alive, but still do not save the
resource to a session, as you never know if the connection will stay alive to
the next php-script, so you need to rerun the mysql_pconnect(), it will check
if the connection is still alive, is so it won't do anything else, but if it
would be so it's dead, then it will reconnect to the sql-server.

http://www.php.net/manual/en/function.mysql-pconnect.php

You will have as many mysql_pconnect() in your code as you did have
mysql_connect(), but you will have less overhead.


//Aho

 

Navigation:

[Reply to this 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

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