I am relatively new to Perl but have found it to be
a very powerful expressive language. Two aspects Perl Im especially
interested in are Patterns and efforts towards enterprise perl.
A pattern which caught my eye recently was
the Apache::Session modules design. I tweaked it slightly so thats its more a
generic persistence layer. Id be interested in discussing this with some people.
Im based in NW London. See below for an example usage.
The benefits of this are that you can all your business objects are hashs and
theres no need to worry about the specific storage used ( ie store as a
serialized hash or as table attributes / switch from MySQL to Oracle ).
TO CREATE NEW OBJECTS IN THE DB:
==============================
for a single key, ----------------------
# if you know the key value you want to
use
my @key = [ "person0001" ] ;
my $aPerson = Person::MySQL->new( @key
)
# if you dont
my $aPerson = Person::MySQL->new(
) # the _personId maps to a personId key field in the Person table
#then behaves exactly as the Apache::Session object. my $id = $aPerson->{_personId};
and for mutiple keys
-----------------------------
#you want to create a new object using the key
elements(can use some or all )
my @key = [ "person0001", "EMPLOYEE" ]
;
my $anEmp = Person::::Role::MySQL->new( @key
)
# if you dont
my $anEmp = Person::Role::MySQL->new(
) # the _personId maps to a personId key field in the Role table
# the _roleId maps to a roleId key field in the Role table my $id = $anEmp->{_personId}; my $role = $anEmp->{_roleId};
TO READ OBJECTS FROM THE DB
===========================
for a single key, ----------------------
my @key = [ "person0001" ] ;
my $aPerson = Person::MySQL->readFromDB( @key
)
for n keys,
---------------
my @key = [ "person0001", "EMPLOYEE" ]
;
my $anEmployee =
Person::Role::MySQL->readFromDB( @key );
You get the idea anyway. |
- Re: Interested in coming to a meeting and talking about Gen... Scott Bradley
- Re: Interested in coming to a meeting and talking abou... Greg McCarroll