[mapserver-users] PHP MapObj serialization?

Puneet Kishor pkishor at GeoAnalytics.com
Tue Jul 30 16:55:50 EDT 2002


Here is an alternative with a similar bent...

save all the variables that create any given map into a hash. Then serialize
the hash and store it in a cookie (if small enough) or in a database such as
MySQL. Later retrieve the serialized hash, unserialize it, and reconstruct
the map.

I use the above technique and it works quite well.

pk/

> -----Original Message-----
> From: woodbri at swoodbridge.com [mailto:woodbri at swoodbridge.com]
> Sent: Tuesday, July 30, 2002 8:50 AM
> To: Vinko Vrsalovic; mapserver-users at lists.gis.umn.edu
> Subject: Re: [mapserver-users] PHP MapObj serialization?
> 
> 
> Vinko,
> 
> You can not serialize the map object as it is not a php object be a 
> containor for a C structure. What you would have to do is save the 
> currect map object as a mapfile in a temp directory using a unique 
> file name and save the file name in the session variables, then 
> restore the map object from the map file you saved.
> 
> -Steve W.
> 
> On 30 Jul 2002 at 1:44, Vinko Vrsalovic wrote:
> 
> > Hello, 
> > 
> > 	I'm trying to serialize a PHP MapObj for further use (another
> > 	page from the same session).
> > 
> > 	From what I've read, this will not work if you don't have the
> > 	definition of the class in all the pages the object will be
> > 	used.
> > 
> > 	I also presume that dl'ing the .so is not what is meant by
> > 	definition of the class. Is serializing and/or saving in a
> > 	session variable the mapobj possible?
> > 
> > 	Ex:
> > 
> > 	p1.php
> > 	<?php
> > 	dl('php_mapscript.so');
> > 	session_start();
> > 	$map = ms_newMapObj("file.map");
> > 	$map->draw();
> > 
> > 	$_SESSION['map'] = $map; 
> > 	/* or
> > 	$_SESSION['map'] = serialize($map);
> > 	*/
> > 
> > 	?>
> > 
> > 	p2.php
> > 	<?php
> > 	dl('php_mapscript.so');
> > 	session_start();
> > 	$map = $_SESSION['map'];
> > 	/* or
> > 	$map = unserialize($_SESSION['map']);
> > 	*/
> > 
> > 	?>
> > 
> > 	As I understood from the docs the serialization is not 
> needed when
> > 	using $_SESSION.
> > 
> > 	If i serialize/unserialize, i get the long forgotten:
> > 
> > 	Fatal error: Object has an invalid _handle_ property in ...
> > 
> > 	If i don't serialize/unserialize, i get the same error. :)
> > 	
> > 	Is there a trick to make PHP see the MapObj definition?
> > 
> > Thanks,
> > -- 
> > Vinko Vrsalovic <vinko[|- at -|]cprsig.cl>
> > http://www.cprsig.cl
> > 
> 
> 



More information about the mapserver-users mailing list