Re: Interesting problem in PHP and Squirrelmail

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2006-01-18 at 15:36, Mark wrote:
>
> [-- CLIPPED --]
>
> Here's a point of debate, should this sort of behavior be allowed? If it is
> allowable, how does one support it in any sort of serialized methodology? I
> have a few ideas but none very pretty. I'm pretty sure it causes problems
> in regular PHP as these sorts of pages sometimes have problems anyway.

Yes it should be allowed, yes you can serialize it. Look at PHP's
serializer. You'll notice they track recursive structures and properly
unserialize them. One way to do it is to unroll objects into a single
lookup. When you FIRST encounter an object assign it a unique ID (make
it a property on the object that is unlikely to collide with any other),
add the object to the lookup with the UID as the key and continue
serializing, the next time you encounter the object, you know you're
recursing and so in your serializer you have a special marker that
indicates the current object points to an existing serialized object
with the given UID. Then you move onto the next item. Your unserializer
will then be able to traverse the serialized data and as it comes across
objects it can create the same lookup and when it hits the recurse
marker it will know to create a reference to the original.

The implementation is slightly more difficult than what I've just
described, but simple enough :)

HTH,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux