I need to be able to temporarily store a complete PHP object (containing some data and methods) somewhere… we use MySQL already but I’m open to other solutions if they work better.
Essentially, I can’t use serialize because we lose the methods and I’d rather not save the data, and then create a new instance of the object every time I want to use it.
What’s the best way for storing a complete php object for later use (needs to be saved to memory, using session not ok if user disconnects).
You can use serialize, but you need to include the class file before restoring/unserializing the instance you created and saved. That will restore everything, including methods. You can’t save everything because PHP doesn’t save a copy of everything in the instance.
Basically, you need to include the underlying code, then restore/unserialize. The instance will contain any data changes that had been made prior to serializing/saving.