Updated: 7/23/2002; 11:40:34 PM.
Ham Journalism
Do... not... seek... the... treasure!
        

Tuesday, June 04, 2002

So, lately I've been thinking about things like object persistence. I looked into J2EE and EJB. EJB is really complicated. In fact, one could argue that it's too complicated for the likes of some people. But there is one facet of J2EE that fascinates me, and that is Container-Managed Persistence, or CMP for short.

Basically what CMP does, if I have this correctly, is it allows an object's data fields to reside inside an RDBMS. The object doesn't care how it's data is stored, just that it gets it back from the container.

What I would like to see (implemented in PHP), is something similar. When an object is instantiated, a new row in a database is created. One column per member variable will be used. The object's get/set methods would automatically select/insert the correct data in the object's database row.

Another interesting thing about EJB's is that you can define relationships between objects. For instance, you can create a customer object, and one customer might have multiple shipping addresses, whereas a shipping address may only have one customer (or many, depending how you look at it). Therefore, when a customer object is destroyed, the container realizes that an address object goes along with the customer, and deletes that object as well. Eventually, it depends on the container deleting the correct corresponding rows from each object's respective tables.

There are some problems with this, however. The first one, is that there isn't a PHP process that is always running, such as is the case in a Java servlet environment. Another problem that I see is that the "container", in this case, Apache/PHP, isn't really capable of managing objects this way. Therefore, the persistence would have to be implemented directly into the class.

This sort of automated functionality would be very useful in a PHP application. Developers could spend more time architecting a program, instead of having to worry about making sure to delete the correct tables in a database, updating multiple tables when certain data changes, etc.

The problem is, I believe, that PHP as it currently stands is unable to handle this kind of complex behavior. There's no threading of processes in PHP, and pages execute from top to bottom, and then the script is dead. Poof.

Anyone have any ideas on this subject? Mail me. The link is on the right side of the page.


10:23:31 PM    comment []


© Copyright 2002 Tony Collen.
 
June 2002
Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            
May   Jul


Click here to visit the Radio UserLand website.

Subscribe to "Ham Journalism" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.