views:

72

answers:

2

I'm drawing a blank for some reason on how to access this information in an object (It's a Zend_Db_Table_Row, but I think that's beside the point). Here's the print_r, I'd like to get just the array assigned to [_data:protected]

MyClassName Object
(
[_data:protected] => Array
    (
        [param1] => 1
        [param2] => Some info
        [param3] => ....
    )

... lots more unneeded info such as 'cleandata' and table schema information

I know I can access all the data using $instance->param1, etc, but I'm assigning it to a session and would like to just be able to say

$sessionNamespace = $instance->data;

...as to not store the table schema info and not have to iterate through the array and assign it manually. Thanks.

+1  A: 

Because it has :protected, means it has been declared protected and therefore you can't access it. The actual class, or a class derived from it (that extends it) has to pass it to you with a function call.

You might want to check the API for a getData() type method that returns all the data, or serialize() if the object supports serialization.

Edit: And there one is: As Zerkms suggested, you can use toArray() to access it.

Chacha102
+5  A: 

what about Zend_Db_Table_Row::toArray()?

zerkms
Ah of course, thanks! It's been a long night =)
Ryan