GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
SPOPS::Export(3) User Contributed Perl Documentation SPOPS::Export(3)

SPOPS::Export - Export SPOPS objects to various formats

 use SPOPS::Export;

 # Export to internal SPOPS format

 my $exporter = SPOPS::Export->new( 'object',
                                    { object_class => 'My::Object' });

 # Export all objects

 print $exporter->run;

 # Export only certain objects

 $exporter->where( "user_id = 5" );
 print $exporter->run;

 $exporter->where( "last_name = ?" );
 $exporter->value( [ "O'Reilly" ] );
 print $exporter->run;

 my $exporter2 = SPOPS::Export->new( 'xml',
                                    { object_class => 'My::Object' } );

 # Export all objects

 print $exporter2->run;

 # Export only certain objects

 $exporter2->where( "user_id = 5" );
 print $exporter2->run;

 $exporter2->where( "last_name = ?" );
 $exporter2->value( [ "O'Reilly" ] );
 print $exporter2->run;

This is a simple module to export SPOPS objects into a portable format. The format depends on the type of exporting you are doing. Currently we support five formats, each of which has a unique identifier (in parens) that you pass to the "new()" method:
1.
SPOPS::Export::Object (object) An internal format based on serialized perl.
2.
SPOPS::Export::XML (xml) Basic XML
3.
SPOPS::Export::Perl (perl) Standard serialized Perl format using Data::Dumper.
4.
SPOPS::Export::SQL (sql) A series of SQL statements, one for each record.
5.
SPOPS::Export::DBI::Data (dbdata) Almost exactly like 'object' but it can be put directly into a DBI table without using objects.

You can set the following properties in the exporter object. Only one is mandatory.

object_class ($)

Class of the object for which you want to export the data. This should already be created via the normal means (see SPOPS::Initialize).

include_id (bool) (optional)

Whether to include the ID field its values in the exported data.

Default: false

skip_fields (\@) (optional)

Fields for which you do not want to include data.

Default: none

where ($) (optional)

A WHERE clause (or whatever the datasource supports) to export only certain data.

value (\@) (optional)

If you use placeholders in the "where" property, replace them with values here.

new( $export_type, \%params )

Create a new instance of an exporter. Since this is a factory class, we use $export_type to determine the class used to create the exporter object. (The export types and classes are listed above.)

run()

Runs the configured export, returning a string with the exported data.

If you want to write your own exporter, you just need to create a class with the following methods. (Technically, all are optional, but you will not get too far if you do not implement at least "create_record()".)

Also: if you are writing your own exporter, be sure to look at the "add_type()" method defined above.

initialize( \%params )

Perform any necessary initialization for an instance of your exporter object. Return the object.

create_header( \@object_fields )

Return a string with the export header.

create_record( $object, \@object_fields )

Return a string representing the object in the export format you are implementing.

create_footer()

Return a string with the export footer.

None known.

Nothing known.

SPOPS::Manual::ImportExport

Class::Accessor

Class::Factory

Copyright (c) 2001-2004 intes.net, inc.. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Chris Winters <chris@cwinters.com>
2004-06-02 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.