stdClass Object ( [data] => can't seem to access the valu

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
yanisdon
Forum Newbie
Posts: 18
Joined: Thu Jul 06, 2006 10:44 pm

stdClass Object ( [data] => can't seem to access the valu

Post by yanisdon »

Am using PEAR:: DB for establishing and accessing a database.
For getting a result set I use something like this:
$data = $dataRow->fetchRow();

However, this is not the reason for posting. This works fine and the output with print_r($data) echoes something like this:

stdClass Object ( [data] => __HTTP_Session_Info|i:1;__HTTP_Session_Expire_TS|i:1152239116;__HTTP_Session_Idle|i:5;UserName|s:11:"blah";Password
|s:32:"0515105115j1g515gfs1";ShortName|s:3:"sigstus";submit|s:6:"submit";counter|i:0;__HTTP_Session_Idle_TS|i:1152239056; )

Now, I'd like to access the values, e.g. UserName or ShortName

$data->ShortName;

doesn't work...

Even
$now =unserialize($data);
$now->ShortName;

is the wrong approach.

How can I access these values?

Cheers Jan
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

$data->data would be the one and only property of your object. It appears that your class is a value object of a session data string, as such, you may want to look at the code posted in the Database Sessions class we've linked to through the Useful Posts thread.
Post Reply