2007. 03. 27, kedd keltezéssel 16.55-kor Jeff Moore ezt írta: > > 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. Yes a bit late ... as the application submission deadline has already passed. (for SoC)
> 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. The SoC application is over, but this could also be done outside of SoC. I think this is a good project, rethinking the serialization / unserialization support in PHP would be beneficial for many. However don't wait for me to do it, because I won't. > 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. I think I've already explained my opinion on this idea. Your idea is not bad, and I think many agrees with you, but I see things a bit differently. > 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. I generally don't like the idea of converting an object to array and back as it violates most OO principles. Don't convert an object to an array, because than there's no problem with private properties and so on. If someone wants arrays from the database, then he/she souldn't use ORM because it's Object-relational mapping, not Array-relational mapping! > 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? Maybe ... but that is someone else's project, not mine. To see what my goals are how I plan to achieve them, see the archives. I think I've explained a lot on the list. However, if you find any problems with my proposed solution, please don't hesitate to share it with us. > > Best Regards, > > Jeff > Thank you, Adam -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php