package SmallProject::Database; use base 'DBIx::Simple'; sub connect { my $self = shift; $self->SUPER::connect('dbi:...', 'u', 'p', { RaiseError => 1}); } sub foo { my $self = shift; my ($where, @binds) = $self->abstract->where({ @_ }); $self ->query("SELECT * FROM foo WHERE $where LIMIT 1", @binds) ->hash; } # This could be simpler if SQL::Abstract supported LIMIT clauses: # sub foo { # my $self = shift; # $self->select(foo => '*', { @_ }, \1); # } sub foos { my $self = shift; $self->select(foo => '*', { @_ })->hashes; } 1; #### my $db = SmallProject::Database->new; my $foo = $db->foo(id => 15); my @active_foos = $db->foos(active => 1);