Page 1 of 1
Object Persistence?
Posted: Tue Feb 03, 2009 11:48 am
by chadlong41
Is there object persistence in PHP 5?
I ask because it seems that with all the associated memory overhead with OOP, I am wondering if there is another reason for PHP to go OO besides maintainability.
Re: Object Persistence?
Posted: Tue Feb 03, 2009 11:52 am
by mickeyunderscore
The only way I know of to accomplish object persistence is to serialize them into a cookie, or something else that you can retrieve again on the next request.
Re: Object Persistence?
Posted: Tue Feb 03, 2009 12:03 pm
by Christopher
chadlong41 wrote:Is there object persistence in PHP 5?
You can put them in the session. Just assign to $_SESSION. It will even serialize for you. You can serialize an object and save it to any datasource. Obviously if it has things like file handles and database connection you will need to deal with those. There are wake/sleep methods to do that too.
chadlong41 wrote:I ask because it seems that with all the associated memory overhead with OOP, I am wondering if there is another reason for PHP to go OO besides maintainability.
If you only use OO for maintainability and actually have a problem with memory usage, then you may not want to use OO.