Re: Persistent state applications

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



1) PHP applications are built on the concept of shared-nothing.  Every page 
request is, and should be, entirely independent of another.  That is by 
design.  It's weird if you're used to stateful programming (desktop, JSP, 
etc.), but it is actually very powerful.

2) If you really need to persist something, keep it small and use sessions[1].  
They exist for that purpose.

3) 95% of the time, persistent connections to SQL servers are more trouble 
than they're worth.  If you're using MySQL or SQLite in particular, the 
connection cost is tiny.  In practice it's better to just let the connection 
die at the end of the request and re-open it at the start of the next 
request.  The web has been optimized over the past decade for that usage 
pattern.

[1] http://www.php.net/sessions

On Saturday 17 May 2008, James Colannino wrote:
> Hey everyone!  I'm very new to PHP, and had a somewhat general question
> (forgive me if it's too broad in scope.)  Basically, I'd like to be able
> to have a single PHP application that remembers its state as users click
> on links.  When the user clicks on a link, though, the user unavoidably
> re-requests the URL from the web server, which forces the PHP
> application to reload.  I'm therefore uncertain as to how I should keep
> the program in a state in which it remembers things like login
> information when the users have to click on links in order to navigate
> the application.
>
> This is especially an issue for me when it comes to maintaining things
> like persistent connections to SQL servers.
>
> Thanks!
>
> James


-- 
Larry Garfield			AIM: LOLG42
larry@xxxxxxxxxxxxxxxx		ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux