You are here: Re: connection from one page to another « PHP Programming Language « IT news, forums, messages
Re: connection from one page to another

Posted by Dikkie Dik on 12/06/05 00:37

That depends. If the instance is to be kept in one "build" of your page
(your different pages are included and/or required) you can keep it in a
(global) variable.
If it has to exist along mutiple client requests, it is another story.
HTTP is a stateless protocol, so once the page has been sent to the
client, all is over and forgotten. No state is kept.
Now this can be "repaired" with sessions if you use them. However, a
session is nothing more than a storage "just in case the client comes
back". Web applications lead a very fragmented life.
Especially a database connection is not something I would store between
sessions. There is a major chance that the client does not come back
(every website visitor leaves at SOME point) and you would end up
keeping connections open that are not used anymore.

If you do want an object stored in the session, just keep it in the
SESSION array (a superglobal). Beware that the classes have to be
defined (and timely) in every page that can encounter such an object.

Best regards

gachsaran wrote:
> Hi
>
> I have a class that is my interface to mysql. I create an instance og
> class an connect to db. Then i change to another page and want to use
> the same instace of class. How can i send an object (the instance) to
> another page ?
>
>
> Any help will be appricated.
> Gachsaran

 

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

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