Hi,

Sorry, I'm coming to this discussion a bit late and perhaps I don't understand the all issues, but I think the scope of creating an ORM for PHP is probably too large. Let me suggest a smaller project that could lead to better ORM.

PHP has several methods of serializing and unserializing objects to different formats:

PHP serialization format using serialize/unserialize (with __sleep, __wakeup and the Serializable interface)
PHP code using var_export and eval (with __set_state)
JSON using json_encode and json_decode
Partial support for DB Records using mysql_fetch_object or PDOStatement->fetchObject()

Its safe to assume that other serialization formats are possible.

All of these methods have to address the same issues with objects:

How to handle protected and private properties?
To call or bypass the constructor on unserialization?
Can objects become involved with their own serialization? (such as __sleep, __wake, __set_state, and Serializable) Must objects become involved with their own serialization (such as with var_export and __set_state) or can you serialize unaware objects? Are object relationships and identity preserved? (only true for serialize/unserialize right now)
How are classes loaded? (unserialize_callback_func and __autoload?)

I think a more limited scope project would be to attempt to address these core object serialization issues across the multiple formats that PHP already provides in some consistent way. Of course, not every capability is possible or necessary with every format.

Before implementing ORM in C, which would be relatively less flexible than a PHP implementation, perhaps it would be a good idea to profile the existing PHP ORM solutions and look for opportunities to implement key functions in C, while leaving the majority to user space.

A possible example of such an opportunity might be some equivalent to extract() and compact() only for converting between arrays and object properties instead of arrays and local variables.

Rather than implement a full blown ORM extension, perhaps implementing some object serialization enhancements would be a good alternative, or at least a good first step? Perhaps some user space ORM profiling would be a good way to find the second step?

Best Regards,

Jeff

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to