PHPWomen Site Home » Programming » PHP Coding » saving state of an object
saving state of an object [message #3168] Thu, 10 June 2010 09:35 Go to next message
evejones  is currently offline evejones
Messages: 9
Registered: December 2008
Location: UK
Shiny and New
Hi,
Im learning OO php. I know a reasonable amount of Java so Im ok with OO theory generally. My problem is how do i save an objects state in php as http is stateless. when resubmititng the form i want the object`s state to be available. The solution I can think of is passing the values i need saved to a session and with url rewriting as backup and then getting those values back when the form is resubmitted. Maybe Im missing something as I have only just started with OO php but I can not see how it would work otherwise. Anything more elegant would be appreciated or is it acceptable practice to do it this way?
Thanks for any help.
Re: saving state of an object [message #3171 is a reply to message #3168 ] Mon, 14 June 2010 14:44 Go to previous messageGo to next message
KathyReid  is currently offline KathyReid
Messages: 226
Registered: October 2006
Location: Geelong, Victoria, Austra...
Member
Hi Eve,

It depends of course on the structure of your program, but I'd be inclined to use sessions and store the object as a session variable;

http://www.php.net/manual/en/book.session.php


Regards,
Kathy
Re: saving state of an object [message #3173 is a reply to message #3168 ] Tue, 15 June 2010 13:52 Go to previous message
evejones  is currently offline evejones
Messages: 9
Registered: December 2008
Location: UK
Shiny and New
Thanks Kathy.
I`m using an m-v-c architecture with a single point of entry ( the controller). I was wondering what alternatives to sessions for storing object states there are within php? I`m playing with the code a bit here as I am learning how to do OO php within a component and service based framework. Im attempting to do a jsp/servlet approach using the basics of J2EE as applied to php.
Also I was wondering what is the equivalent of a java bean in php ? I know objects can be serialised but I`m not at all sure how to write any listeners without resorting to using someone elses library. Any tips and tricks would be much appreciated.
Previous Topic:HTML::ParseTree
Next Topic:need of GET when POST can handle!
Goto Forum:
  


Current Time: Fri Sep 3 19:31:47 EDT 2010

Total time taken to generate the page: 0.01736 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.0.
Copyright ©2001-2006 FUD Forum Bulletin Board Software