Re: [PHP] Object Reference Serialization

2002-05-03 Thread Adam Langley

No worries...I just realized that my object never repopulated the underlying
classes with previous object references...Thanks guys, but I see my problem
now...

Cheers.

Adam Langley.


"Thies C. Arntzen" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Fri, May 03, 2002 at 12:34:01AM +1200, Adam Langley wrote:
> > Hi everyone,
> >
> > Im trying to store an object which contains an associative array of
classes,
> > each of which contains an array of classes, so a 3-tier hierachy, in the
> > session object. However, the final tier gets lost upon
> > serialization/deserialization, why is this and how can I prevent this
from
> > happening?
>
> send us a minimal testcase...
> tc
>
> >
> > Thanks in advance.
> >
> >  - Adam Langley
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php



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




Re: [PHP] Object Reference Serialization

2002-05-03 Thread Adam Langley

OK, heres all the code...

I have a BoundForm class, a BoundFormPage class, and a BoundTextField...

I create a BoundForm, add a BoundFormPage object to it, then add a
BoundTextField to the BoundFormPagethen I add the root node (the
BoundForm) to the SESSION...

The Form, and Page survive serialization, but not the TextField...I dont
know why.



// these are the class definitions

class BoundTextField{

var $name;

var $value;

function BoundTextField($name, $size, $value=""){

$this->name = $name;

print "\n";

}


function isValid(){

if (strlen(trim($value))>0){

return true;

} else {

return false;

}

}

}

class BoundForm{

function BoundForm($lName){

$name = $lName;

print "count = ".count($pages);

}

var $action;

var $method;

var $name;


var $dbName;


var $pages;



// upon instantiation, write form to session object.


function addPage($page){

if (!isset($this->pages[$page->name])){

print "adding page";

$this->pages[$page->name] = $page;

} else {

// this page already exists, so we dont want to replace it,

// or it will lose all its stored data...

print " ".$this->pages[$page->name]->name." already exists\n";

}

}

}

class BoundFormPage{

// these are the fields (BoundFormElements) that you can add to a form page.

var $fields;

var $name;


function BoundFormPage($lName){


$this->name = $lName;

//$myTextField = new BoundTextField("No", 30);

}

// will determine if the page has been successfully filled in.

function isComplete(){

for(reset($fields);$key = key($fields);next($fields)){

if (!$fields[$key].isValid()){

return false;

}

}

}

function addField(&$field){

print $field->name;

print "".count($this->fields)."";

if (!isset($this->fields[$field->name])){

print("adding field ".$field->name);

$this->fields[$field->name] = $field;

} else {

// this page already exists, so we dont want to replace it,

// or it will lose all its stored data...

print "already exists".$this->fields[$field->name]->name."\n";

}

}

}

//--

//and this code execute the sample classes above...

// get our form object back, but dont overwrite it

if (!session_is_registered("myForm")){

$myForm = new BoundForm("Application Form");

session_register("myForm");

} else {

//return $_SESSION[$formName];

session_register("myForm");

}

// construct the hierachy (note that all 'add' methods will not overwrite
existing children of same names)

$firstPage = new BoundFormPage("pageOne");

//$myTextField2 = new BoundTextField("gumber", 30);

//$firstPage->fields[$myTextField2->name] = $myTextField2;

$myTextField = new BoundTextField("CustomerNumber", 30);

$firstPage->addField($myTextField);

$myForm->addPage($firstPage);

"Thies C. Arntzen" <[EMAIL PROTECTED]> wrote in message
news:<[EMAIL PROTECTED]>...

> On Fri, May 03, 2002 at 12:34:01AM +1200, Adam Langley wrote:

> > Hi everyone,

> >

> > Im trying to store an object which contains an associative array of
classes,

> > each of which contains an array of classes, so a 3-tier hierachy, in the

> > session object. However, the final tier gets lost upon

> > serialization/deserialization, why is this and how can I prevent this
from

> > happening?

>

> send us a minimal testcase...

> tc

>

> >

> > Thanks in advance.

> >

> > - Adam Langley

> >

> >

> >

> > --

> > PHP General Mailing List (http://www.php.net/)

> > To unsubscribe, visit: http://www.php.net/unsub.php




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




Re: [PHP] Object Reference Serialization

2002-05-02 Thread Thies C. Arntzen

On Fri, May 03, 2002 at 12:34:01AM +1200, Adam Langley wrote:
> Hi everyone,
> 
> Im trying to store an object which contains an associative array of classes,
> each of which contains an array of classes, so a 3-tier hierachy, in the
> session object. However, the final tier gets lost upon
> serialization/deserialization, why is this and how can I prevent this from
> happening?

send us a minimal testcase...
tc

> 
> Thanks in advance.
> 
>  - Adam Langley
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

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




[PHP] Object Reference Serialization

2002-05-02 Thread Adam Langley

Hi everyone,

Im trying to store an object which contains an associative array of classes,
each of which contains an array of classes, so a 3-tier hierachy, in the
session object. However, the final tier gets lost upon
serialization/deserialization, why is this and how can I prevent this from
happening?

Thanks in advance.

 - Adam Langley



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