Date: 10/28/99
- Next message: carmelo: "[PHPLIB-DEV] cvs commit"
- Previous message: xendra: "Re: [PHPLIB-DEV] PHPLIB-7.2 released"
- In reply to: Kristian Köhntopp: "[PHPLIB-DEV] Re: [PHPLIB] phplib - changes proposal"
- Next in thread: Sascha Schumann: "serialize() (was Re: [PHPLIB-DEV] Re: [PHPLIB] phplib - changes proposal)"
- Reply: Sascha Schumann: "serialize() (was Re: [PHPLIB-DEV] Re: [PHPLIB] phplib - changes proposal)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Kristian Köhntopp wrote:
>
> Teodor Cimpoesu wrote:
> > oh, I see! That was one thing I ignored cause I didn't undestood
> > why exatcly would one need persistent slots. On the other hand,
> > if I want all the properties of an object to be persistent that
> > would generate a long code of $this->property=val assignments
> > instead of a simple string.
>
> Which, if constant, need not to be persistent in itself. But you
> are right, the default is backwards and should be "serialize
> everything". Boris Erdmann once wrote a version of serialize
> which did this correctly.
>
> Kristian
>
Hmm,
no. My version checks if a persistent_slots array is available.
If so, it would serialize the slots listed in there. If not, the
whole object got serialized.
The old serializer should painlessly be replaceble by
the following (maybe with little modifications at
where _serialize() is called):
-----
## _serialize($var,&$ser):
##
## appends a serialized representation of $$var
## at the end of $ser.
function _serialize($var, &$ser) {
static $k;
eval('$k = gettype($'.$var.');');
switch ( $k ) {
case "integer":
case "double":
case "string":
eval('$ser.="$$var=\'".ereg_replace("\'","\\\'",$'.$var.')."\';";');
break;
case "array":
eval('
$ser.="$$var=array();";
reset($'.$var.');
while ( list($k) = each($'.$var.') ) {
_serialize("${var}[\'".ereg_replace("\'","\\\'",$k)."\']", $ser);
}
');
break;
case "object":
eval('
$ser.="$$var=new ".$'.$var.'->classname.";";
if ( is_array($'.$var.'->persistent_slots) ) {
reset($'.$var.'->persistent_slots);
while ( list(,$k) = each($'.$var.'->persistent_slots) ) {
_serialize( "${var}->".$k, $ser );
}
} else {
reset($'.$var.');
while ( list($k) = each($'.$var.') ) {
_serialize( "${var}->".$k, $ser );
}
}
');
break;
default:
;
break;
}
}
-----
Boris
-
PHPLIB Developers Mailing List. Send messages to <phplib-dev <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-dev-request <email protected>> in
the body, not the subject, of your message.
- Next message: carmelo: "[PHPLIB-DEV] cvs commit"
- Previous message: xendra: "Re: [PHPLIB-DEV] PHPLIB-7.2 released"
- In reply to: Kristian Köhntopp: "[PHPLIB-DEV] Re: [PHPLIB] phplib - changes proposal"
- Next in thread: Sascha Schumann: "serialize() (was Re: [PHPLIB-DEV] Re: [PHPLIB] phplib - changes proposal)"
- Reply: Sascha Schumann: "serialize() (was Re: [PHPLIB-DEV] Re: [PHPLIB] phplib - changes proposal)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

