[mapserver-users] PHP MapObj serialization?

woodbri at swoodbridge.com woodbri at swoodbridge.com
Tue Jul 30 06:49:57 PDT 2002


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