PHP Object Persistence

Hi fellas,

First, sorry for any typos, I’m from Brazil =]

I need to make my User class persist. Is it possible with PHP?

Thanks in advance.

@Gerep: It is indeed possible to persist - but the subject is so big that it may be more appropriate for you to do some research into the subject before asking the question. Answering your question from scratch may be a little too much for the scope of a forum post, and there are several threads that deal with this topic already.

i.e.

I suggest you do some research in the following Google results, and then come back with more specific questions:
http://www.google.co.uk/search?source=ig&hl=en&rlz=&=&q=Domain+Model+PHP&aq=f&aqi=g10&aql=&oq=&gs_rfai=
http://www.google.co.uk/search?hl=en&safe=off&q=Active+Record+PHP&aq=f&aqi=g-c1&aql=&oq=&gs_rfai=
http://www.google.co.uk/search?hl=en&safe=off&q=Doctrine+PHP&aq=f&aqi=g10&aql=&oq=&gs_rfai=
http://www.google.co.uk/search?hl=en&safe=off&q=Redbean+PHP&aq=f&aqi=g1g-sx1&aql=&oq=&gs_rfai=
http://www.google.co.uk/search?hl=en&safe=off&q=data+mapper+php&aq=f&aqi=g1&aql=&oq=&gs_rfai=

Gerep, PHP is usually stateless, which means each page requests is isolated from the others. The server doesn’t (normally) maintain objects in memory between request, they get rebuilt each time. So for a login system the user normally carries a session ID in a cookie which can then be used to access data to rebuild the object on each request.

What do you mean by “persist my user class” ?

Ok G.Schuster, but just be patient and do you really think I would waste time just wondering if it is possible without the need of help? I see you have experience with it but I DON’T, so don’t bother wasting your precious time answering “yes” trying to be useful ok? Thanks!

Anyone else can help with this issue? I need to persist my User class, I’ve found a thread here but it dates 2007 =/

Thanks in advance.

Yes.

G.Schuster, have any link?

Sorry, but please be more precise with what you have and what you want to achieve.
Just asking if it is possible to do X with Y leaves too much space for imagination for all potential helpers.
http://www.sitepoint.com/forums/showthread.php?t=681033 might be a good read.

Can’t you just map the users data stored in the session back to your user object every request?