my $user = MyUserClass->new( {u_name=>"mrwong",u_password=>"jshdghjashjd"}); $user->save; #### #!/usr/bin/perl -w use SPOPS; use MyUserClass; { SPOPS::set_global_debug( debug => 1 ); my $otherUser = MyUserClass->fetch(4); foreach my $key ( keys %$otherUser ) { print "Key $key: $otherUser->{$key}\n"; } } #### package MyUserClass; use strict; use SPOPS::Initialize; my $spops = { 'users' => { class => 'MyUserClass', field => [ 'u_name', 'u_password' ], isa => [qw/Datasource SPOPS::DBI::Pg SPOPS::DBI/], id_field => ['u_id'], base_table => 'users', field_discover => 'no', }, }; { SPOPS::Initialize->process( { config => $spops } ); } sub new { my $proto = shift; my $class = ref($proto) || $proto; my $self = {}; my $vars = shift; foreach my $key ( keys %{$vars} ) { $self->{$key} = $vars->{$key}; } bless $self, $class; return $self; } #### package Datasource; use strict; use DBI; my ($dbh); sub global_datasource_handle { my ($class) = @_; return $dbh if ($dbh); $dbh = DBI->connect( 'DBI:Pg:dbname=xxx', 'xxx', 'xxx', { RaiseError => 1, PrintError => 0 } ); unless ($dbh) { die "Cannot create database handle! Error: $DBI::errstr\n"; } return $dbh; } 1; #### SPOPS::ruleset_process_action (323) >> Trying to process pre_fetch_action for a MyUserClass type of object SPOPS::clear_all_loaded (399) >> Clearing all fields to unloaded for object class MyUserClass Can't use an undefined value as a HASH reference at /usr/lib/perl5/site_perl/5.8.0/SPOPS.pm line 400. Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/site_perl/5.8.0/SPOPS.pm line 173.