ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Serialize / Unserialize object array

May 27, 2011 5:37pm

Subscribe [2]
  • #1 / May 27, 2011 5:37pm

    megayo

    1 posts

    Hi everybody,

    I’m new in the forum and I have the following problem. I have a function which retrieves an array of serialized objects and which later I pass place into the session userdata. The problem comes when I try to unserialize each object and use any of the function defined at the object class. When make a var_dump of one of the unserialized object I get the following result.

    object(__PHP_Incomplete_Class)#20 (6) {
    ["__PHP_Incomplete_Class_Name"]=>
    string(5) "Clase"
    ["id":"Clase":private]=>
    string(1) "1"
    ["nombre":"Clase":private]=>
    string(13) "Comp"
    ["codigo":"Clase":private]=>
    string(5) "C"
    ["periodo":"Clase":private]=>
    string(19) "Otono"
    }

    The strange thing is that I tried retrieving the array of the serialized objects from the session user data at the same controller just after I set them into the session user data, and when I execute a var_dump of one of the unserialized object and I don’t get the PHP_Incomplete_Class message.

    What can I be doing wrong? Thanks in advance.

    Regards

  • #2 / May 27, 2011 8:01pm

    theprodigy

    653 posts

    Take a look at this PHP page.

    In order to be able to unserialize() an object, the class of that object needs to be defined. That is, if you have an object of class A and serialize this, you’ll get a string that refers to class A and contains all values of variables contained in it. If you want to be able to unserialize this in another file, an object of class A, the definition of class A must be present in that file first.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases