Le 14.05.2013 19:57, Sergiy Zuban a �crit :
> --
Hi Sergiy,
The benefit of using an ORM is to give you objects on which you can
invoke methods. If all you want is raw data, then maybe you are better
off by calling DBI directly. Furthermore, all type conversions in DBIDM
depend on handlers associated to column names; so if that information is
lost, it is no longer possible to apply those handlers. This would mean
that data in array results would not be the same as data in hash
results, which would be quite confusing. So I'm not much in favor of
adding arrays as a new feature in DBIDM API.
This being said, there are 2 ways to get arrays while still working with
DBIDM :
a) use DBIDM to generate the request, and then use DBI to fetch the results.
my $sth = $source->select(-where => \%criteria, -result_as => 'sth');
while (my @row = $sth->fetchrow_array) {...}
b) use a fast statement, and just exploit the hash values
my $fast_stmt = $source->select(-where => \%criteria, -result_as =>
'fast_statement');
while (my row = $fast_stmt->next) {
say join ";", values %$row;
}
Solution b) has the advantage of applying the column handlers, while
solution a) only gives you raw data. Solution b) should be quite fast
because it reuses the same memory locations for each row; but solution
a) is probably event faster. Have a look at
https://github.com/damil/compare-ORM if you are interested in benchmarks.
Cheers, Laurent D.