Exporting MgdSchema objects

Posted on 2006-08-28 14:36:09 EEST.


Midgard CVS HEAD supports nice and quite usefull export method for MgdSchema objects. It is quite simple to export objects on PHP level.

A code example for exporting whole sitegroup ( SG0 in this case ):

foreach ($_MIDGARD['schema']['types'] as $type => $val){
$replication_data_dir = "/some/path"; $qb = new midgard_query_builder($type); $qb->add_constraint("guid", "<>", " "); $ret = $qb->execute();
foreach ($ret as $object){
$filepath = $replication_data_dir."/".$type."_".$object->guid.".xml"; $dump_file = fopen($filepath, 'w'); $xml = $object->export();
if($xml) { fwrite($dump_file, $xml); fclose($dump_file); } else { echo mgd_errstr(); } } unset($object); }

If you try to execute this code twice , you should get MGD_ERR_OBJECT_EXPORTED errno returned for every export method call.

Back

Layout Copyright © 2006 Finnish Teleservice Center Ltd Oy - Site Powered by Midgard CMS