Log in

View Full Version : About OOP



JasonDFR
01-28-2009, 07:08 AM
I have been experimenting with Object Oriented PHP and have a couple questions.

1) How do I make objects persist? With variables, you can use SESSION, but what about objects? I found this:

$client_object = &$_SESSION['client_object'];
$client_object = new Client( $client_id );

http://blas.phemo.us/articles/2008/05/11/serializing-objects-into-session-data-for-object-persistence-in-php

but haven't tried it out yet. Going to now.

2) Can you describe an object oriented database and how it is different from a relational one? I've read the wikipedia entry on OO database, but it still left me with some questions.

and somewhat related: Anyone have any experience with Amazon Simple DB?

Thanks in advance.

J

Twey
01-28-2009, 11:23 AM
1) How do I make objects persist? With variables, you can use SESSION, but what about objects? I found this:That's exactly the same as saying $_SESSION['client_object'] = new Client($client_id);. I think it should work, since all PHP objects can be serialised.
2) Can you describe an object oriented database and how it is different from a relational one? I've read the wikipedia entry on OO database, but it still left me with some questions.Well, the main difference is that it represents records as objects rather than rows :) Native object databases aren't very commonly used, although ORMs are quite popular.

JasonDFR
01-29-2009, 07:52 AM
Thanks for the reply Twey.

What do you think the best way to handle a "User" class would be? Rebuild the class from a db every page load or try to figure out some way to keep it in server memory? I have been reading about this and there seems to be a big debate on a lot of blogs and forums.

What is an ORM? (Object Relational ...?)

Thanks !