ActiveRecord-Simple
view release on metacpan or search on metacpan
0.65 2014-09-26
+ Dependancy on SQL::Translator now is optional (thanks to @kberov)
+ Added Credits - list of contributors (see README)
* Fixed bugs
* Improved tests
0.70 2015-08-14
+ Added ARS_TRACE
+ Created method "update" for quick objects update
+ New mars command "--upload"
* Improved `find` and `count` methods, now you can use find({ id => [1, 2, 3] }) as '.. where id in (1, 2, 3)'
* Improved error handling
* Method `new` now takes simple hashes (not only hashrefs)
* Improved documentation
0.80 2016-01-05
+ Added method "abstract"
+ Added method "select"
+ Added method "update"
+ Added method "abstract"
lib/ActiveRecord/Simple/Find.pm view on Meta::CPAN
else {
my $object_data = $sth->fetchrow_hashref() or return;
my $obj = $class->new($object_data);
$self->_finish_object_representation($obj, $object_data, $read_only);
delete $self->{has_joined_table};
return $obj;
}
}
sub upload {
my ($self, $param) = @_;
my $o = $self->fetch($param);
$_[0] = $o;
return $_[0];
}
sub next {
my ($self, $n) = @_;
lib/ActiveRecord/Simple/Find.pm view on Meta::CPAN
The same as "with" method
=head2 uplod
Fetch object from database and load into ActiveRecord::Simple::Find object:
my $logs = Log->find({ level => ['error', 'fatal'] });
$logs->order_by('level')->desc;
$logs->limit(100);
$logs->upload;
print $_->message for @$logs;
=head2 to_sql
Show SQL-query that genereted by ActiveRecord::Simple::Find class:
my $finder = Log->frind->only('message')->order_by('level')->desc->limit(100);
print $finder->to_sql; # prints: SELECT message FROM log ORDER BY level DESC LIMIT 100;
t/09-find.t view on Meta::CPAN
is scalar @list, 2;
ok @list = Customer->objects->find->order_by('id')->offset(2)->fetch, 'offset';
is $list[0]->id, 3;
is scalar @list, 4;
undef @list;
$Bill = Customer->objects->find({ first_name => 'Bill' });
ok $Bill->upload;
@list = Customer->objects->find->order_by('first_name')->desc->order_by('id')->asc->fetch;
is $list[0]->first_name, 'Lady', 'order_by does work';
undef @list;
@list = Customer->objects->find->group_by('first_name', 'age')->fetch;
is scalar @list, 5, 'group_by, got 4 objects';
my $count = Customer->objects->find->count;
( run in 1.378 second using v1.01-cache-2.11-cpan-b16cb0d3907 )