NAME
ActiveRecord::Simple::QueryManager - query manager for ActiveRecord classes
DESCRIPTION
Query manager for ActiveRecord classes.
SYNOPSIS
my $qm = ActiveRecord::Simple::QueryManager->new;
$qm->{caller} = 'User';
my @users = $qm->all(); # SELECT * FROM user;
my @johns = $qm->find({ name => 'John' })->fetch;
sql_fetch_all
Execute any SQL code and fetch data. Returns list of objects. Accessors for all not specified fields will be created as read-only.
my @values = Purchase->sql_fetch_all('SELECT id, amount FROM purchase WHERE amount > ?', 100);
print $_->id, " ", $_->amount for, "\n" @values;
sql_fetch_row
Execute any SQL and fetch data. Returns an object.
my $customer = Customer->sql_fetch_row('SELECT id, name FORM customer WHERE id = ?', 1);
print $customer->name, "\n";
find
Returns ActiveRecord::Simple::Find object.
my $finder = Customer->find(); # it's like ActiveRecord::Simple::Find->new();
$finder->order_by('id');
my @customers = $finder->fetch;
all
Same as __PACKAGE__->find->fetch;
get
Get object by primary_key
my $customer = Customer->get(1);
# same as Customer->find({ id => 1 })->fetch;