Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #11735

Re: accessing nested unknown unserialized objects

From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.php
Subject Re: accessing nested unknown unserialized objects
Date 2013-11-05 08:12 -0500
Organization A noiseless patient Spider
Message-ID <l5aqrc$dhm$1@dont-email.me> (permalink)
References <73a48b65-ce17-461c-92a5-d681547aa4c9@googlegroups.com>

Show all headers | View raw


On 11/4/2013 3:37 PM, catseye.chandra@gmail.com wrote:
> Hello PHP users,
>
> I'm currently fiddling with phpgallery 1.x import/tweaking, and by using unserialize got access to an album metadata.
>
> unserialize gives a big array, with nested objects as each elt.
>
> I cannot find the right way to wright the accessor to two fields of real interest :
>
> $this->image->name
>
> and
>
> $this->caption
>
>
> for now I got :
>
> <?
> $fh = fopen("photos.dat", "r");
> $buf = fread($fh, 1024000);
> $arr = unserialize($buf);
> foreach ($arr as &$o) {
>        print $o->image->name;
>        print $o->caption;
>        flush();
> }
> ?>
>
> also:
>
> <?
> $fh = fopen("photos.dat", "r");
> $buf = fread($fh, 1024000);
> $arr = unserialize($buf);
> foreach ($arr as &$o) {
>         //print_r($o);
>         printf("%s : %s\n", $o->image->name, $o->caption);
>         flush();
> };
> ?>
>
> but nothing get printed :-(
>
> Thanks for any help - I'm a beginner.
>
> --
>
> Array
> (
>    [0] => __PHP_Incomplete_Class Object
>        (
>            [__PHP_Incomplete_Class_Name] => AlbumItem
>            [image] => __PHP_Incomplete_Class Object
>                (
>                    [__PHP_Incomplete_Class_Name] => Image
>                    [name] => aaa
>                    [type] => jpg
>                    [width] => 700
>                    [height] => 525
>                    [resizedName] => aaa.sized
>                    [thumb_x] =>
>                    [thumb_y] =>
>                    [thumb_width] =>
>                    [thumb_height] =>
>                    [raw_width] => 1024
>                    [raw_height] => 768
>                    [version] => 38
>                )
>            [thumbnail] => __PHP_Incomplete_Class Object
>                (
>                    [__PHP_Incomplete_Class_Name] => Image
>                    [name] => aaa.thumb
>                    [type] => jpg
>                    [width] => 210
>                    [height] => 158
>                    [resizedName] =>
>                    [thumb_x] =>
>                    [thumb_y] =>
>                    [thumb_width] =>
>                    [thumb_height] =>
>                    [raw_width] => 210
>                    [raw_height] => 158
>                    [version] => 38
>                )
>            [preview] =>
>            [caption] => Gymnocalycium saglione - juin 01
>            [hidden] =>
>            [highlight] => 1
>            [highlightImage] => __PHP_Incomplete_Class Object
>                (
>                    [__PHP_Incomplete_Class_Name] => Image
>                    [name] => aaa.highlight
>                    [type] => jpg
>                    [width] => 200
>                    [height] => 150
>                    [resizedName] =>
>                    [thumb_x] =>
>                    [thumb_y] =>
>                    [thumb_width] =>
>                    [thumb_height] =>
>                    [raw_width] => 200
>                    [raw_height] => 150
>                    [version] => 38
>                )
>            [isAlbumName] =>
>            [clicks] => 4659
>            [keywords] =>
>            [comments] =>
>            [uploadDate] => 994366657
>            [itemCaptureDate] => 992529433
>            [exifData] => Array
>                (
>                    [File size] => 160119 bytes
>                    [File date] => 2004:12:29 22:25:11
>                    [Camera make] => NIKON
>                    [Camera model] => E880
>                    [Date/Time] => 2001:06:14 16:37:13
>                    [Resolution] => 1024 x 768
>                    [Flash used] => No
>                    [Focal length] => 13.9mm
>                    [Exposure time] => 0.0080 s  (1/125)
>                    [Aperture] => f/9.4
>                    [ISO equiv.] => 100
>                    [Metering Mode] => matrix
>                    [Exposure] => program (auto)
>                )
>
>            [owner] => 988373499_1755202938
>            [extraFields] => Array
>                (
>                )
>            [rank] => 0
>            [version] => 38
>            [emailMe] => Array
>                (
>                )
>
>            [imageAreas] =>
>        )
>

$this is only valid in a class member function.  I'm not sure which php 
gallery script you're using (there are several of them with similar 
names), but unless you've created a class with the above information (or 
derived your own class from one with the above information public or 
protected), it won't work.

But you didn't give enough of your code for us to provide any real help.

A couple of suggestions: First, on your development system, turn on all 
error reporting and display the errors.  In your php.ini file, you 
should have:

error_reporting = E_ALL
display_errors = on

(You should have display_errors = off in your production system for 
security reasons).

Second, if you're still having problems, please post enough code so we 
can help you.

P.S. Ignore "Pointed Head".  He's just a troll who jumps on anyone who 
doesn't follow HIS rules of netiquette.  There is no requirement here to 
use a real name (although many of us do).

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Back to comp.lang.php | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

accessing nested unknown unserialized objects catseye.chandra@gmail.com - 2013-11-04 12:37 -0800
  Re: accessing nested unknown unserialized objects Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-05 13:11 +0100
  Re: accessing nested unknown unserialized objects Jerry Stuckle <jstucklex@attglobal.net> - 2013-11-05 08:12 -0500

csiph-web