Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    SPOPS::Manual::Object 0.87

    Download button

    No screenshots available
    Downloads: 366  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Good (3.2/5)
    14 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Chris Winters | More programs
    Perl Artistic License / FREE
    May 12th, 2008, 11:25 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    SPOPS::Manual::Object description

    SPOPS::Manual::Object is a Perl module that shows how you interact with SPOPS objects.

    SPOPS::Manual::Object is a Perl module that shows how you interact with SPOPS objects.

    This section of the SPOPS manual should be of interest to users and developers, since it describes how SPOPS objects are used. Note that all examples here assume the SPOPS class has already been created -- for more on this see SPOPS::Manual::Configuration and SPOPS::Manual::CodeGeneration for more information about that process.

    A Simple Example

    How better to start off than a simple example. Here we get values from CGI.pm, set the values into a new SPOPS object and save it:

    1: my $q = new CGI;
    2: my $obj = MyUserClass->new();
    3: foreach my $field ( qw( f_name l_name birthdate ) ) {
    4: $obj->{ $field } = $q->param( $field );
    5: }
    6: my $object_id = eval { $obj->save };
    7: if ( $@ ) {
    8: ... report error information ...
    9: }
    10: else {
    11: warn " Object saved with ID: $obj->{object_id}n";
    12: }

    You can then display this object's information from a later request:

    1: my $q = new CGI;
    2: my $object_id = $q->param( 'object_id' );
    3: my $obj = MyUserClass->fetch( $object_id );
    4: print "First Name: $obj->{f_name}n",
    5: "Last Name: $obj->{l_name}n",
    6: "Birthday: $obj->{birthdate}n";

    To display other information from the same object, like related objects:

    1: my $user_group = $obj->group;
    2: print "Group Name: $user_group->{name}n";

    And you can fetch batches of objects at once based on arbitrary criteria:

    1: my $q = new CGI;
    2: my $last_name = $q->param( 'last_name' );
    3: my $user_list = MyUserClass->fetch_group({ where => 'l_name LIKE ?',
    4: value => [ "%$last_name%" ],
    5: order => 'birthdate' });
    6: print "Users with last name having: $last_namen";
    7: foreach my $user ( @{ $user_list } ) {
    8: print " $user->{f_name} $user->{l_name} -- $user->{birthdate}n";
    9: }

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    SPOPS objects | object interaction | Perl module | SPOPS | object | interaction

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM