ActiveRecord::Simple::QueryManager - query manager for ActiveRecord classes
Query manager for ActiveRecord classes.
my $qm = ActiveRecord::Simple::QueryManager->new; $qm->{caller} = 'User'; my @users = $qm->all(); # SELECT * FROM user; my @johns = $qm->find({ name => 'John' })->fetch;
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;
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";
Returns ActiveRecord::Simple::Find object.
my $finder = Customer->find(); # it's like ActiveRecord::Simple::Find->new(); $finder->order_by('id'); my @customers = $finder->fetch;
Same as __PACKAGE__->find->fetch;
Get object by primary_key
my $customer = Customer->get(1); # same as Customer->find({ id => 1 })->fetch;
To install ActiveRecord::Simple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ActiveRecord::Simple
CPAN shell
perl -MCPAN -e shell install ActiveRecord::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.