App-Repository
view release on metacpan or search on metacpan
lib/App/Repository.pm view on Meta::CPAN
App::Repository - Logical data access layer for the App::Context Framework, providing a uniform API to access data in databases, file systems, remote web sites, etc.
=head1 SYNOPSIS
use App::Repository;
$context = App->context();
$repository = $context->service("Repository"); # or ...
$repository = $context->repository();
$rep = Repository::Base->new(); # looks for %ENV, then config file
$rep = Repository::Base->new("sysdb"); # looks for %ENV, then config file using "sysdb"
$rep2 = $rep->new(); # copies attributes of existing $rep
$rep = Repository::Base->new(@positional_args); # undefined for Repository::Base
$config = {
'repository' => {
'db' => {
'arg1' => 'value1',
'arg2' => 'value2',
},
'rep2' => {
'arg1' => 'value1',
lib/App/Repository/DBI.pm view on Meta::CPAN
=head1 NAME
App::Repository::DBI - a repository which relies on a DBI interface to a relational database (no caching)
=head1 SYNOPSIS
use App::Repository::DBI;
(see man page for App::Repository for additional methods)
$rep = App::Repository::DBI->new(); # looks for %ENV, then config file
$rep = App::Repository::DBI->new("mysql","mydb","user001","pass001");
$rep = App::Repository::DBI->new("mysql","mydb","user001","pass001","port=3307");
$rep = App::Repository::DBI->new("mysql","mydb","user001","pass001","port=3307","user001");
$ok = $rep->_connect(); # initialize repository (will happen automatically in constructor)
$ok = $rep->_disconnect(); # cleanup repository (will happen automatically in destructor)
$rep->_is_connected(); # returns 1 if connected (ready for use), 0 if not
$errmsg = $rep->error(); # returns the error string for prev op ("" if no error)
$numrows = $rep->numrows(); # returns the number of rows affected by prev op
print $rep->error(), "\n" if (!$rep->_connect());
lib/App/Repository/File.pm view on Meta::CPAN
=head1 NAME
App::Repository::File - a repository which stores its data in flat files
=head1 SYNOPSIS
use App::Repository::File;
(see man page for App::Repository for additional methods)
$rep = App::Repository::File->new(); # looks for %ENV, then config file
$errmsg = $rep->error(); # returns the error string for prev op ("" if no error)
$numrows = $rep->numrows(); # returns the number of rows affected by prev op
print $rep->error(), "\n" if (!$rep->_connect());
$value = $rep->get ($table, $key, $col, \%options);
$value = $rep->get ($table, \%params, $col, \%options);
@row = $rep->get ($table, $key, \@cols, \%options);
@row = $rep->get ($table, \%params, \@cols, \%options);
t/DBI-repobjectset.t view on Meta::CPAN
];
my ($row, $nrows);
#####################################################################
# $value = $rep->get ($table, $key, $col, \%options);
# $rep->set($table, $key, $col, $value, \%options);
#####################################################################
{
my $objset = $context->session_object("adults");
ok(1, "looks good");
my ($objects, $index);
#eval {
# $objects = $objset->get_objects();
#};
#ok($@ =~ /table not defined/, "table not defined");
#$objset->set_table("test_person");
$objects = $objset->get_objects();
ok($#$objects == 6, "got all 7 objects");
$objset->set_params({ "age.ge" => 18 });
$objects = $objset->get_objects();
( run in 0.463 second using v1.01-cache-2.11-cpan-64827b87656 )