Sign in to PrePAN

Database::Accessor Crud for any DB



my $da = Database::Accssor->new({        view     => {name  => 'People'},
        elements => [{ name => 'first_name',
                                 view=>'People' },
                             { name => 'last_name',
                                view => 'People' },
                             { name => 'user_id',
                                view =>'People' } ],
        conditions=>[{left           =>{name =>'First',
                                                      view =>'People'},
                                    right          =>{value=>'Jane'},
                                    operator       =>'=',
                                    open_parenthes =>1,
                                   {condition      =>'AND',
                                    left           =>{name=>'Last_name',
                                    right          =>{ value=>'Doe'},
                                    operator       =>'=',
  $da->add_condition({left           =>{name =>'country_id',
                                                      view =>'People'},
                                    right          =>{value=>22},
                                    operator       =>'=',
                                    condition      =>'AND',
 $da->add_condition({left           =>{name =>'country_id',
                                                      view =>'People'},
                                    right          =>{value=>22},
                                    operator       =>'=',
                                    condition      =>'AND',
 The synopsis above only lists few ways you can use Database::Accessor.


This is the name I finally came up with following alot of test and prototype code and the comments from this

I check about on Cpan the name space is free


and is is sort where I want it to be


This looks useful! I'd like to make a suggestion, though: Instead of creating a {name => "", view => ""} for each element for the "elements" parameter, why not make "elements" take a hashref of {"view" => [name, name, ...]}? It seems this would be more convenient for the user, and your can transform it into the other form internally.

To clarify, the parameter could look something like:

Database::Accssor->new(elements => {People => ["first_name", "last_name", "user_id"]})

This would also eliminate the need for a separate "view" parameter to instantiation, since it would simply be the key-list of "elements".

Please sign up to post a review.