DBIx-DR
view release on metacpan or search on metacpan
lib/DBIx/DR.pm view on Meta::CPAN
If B<true> the method will warn with SQL-request.
=back
=head2 Decamelized strings
Are strings that represent class [ and method ].
foo_bar => FooBar
foo_bar#subroutine => FooBar->subroutine
foo_bar-baz => FooBar::Baz
=head2 perform
Does SQL-request like 'B<UPDATE>', 'B<INSERT>', etc.
$dbh->perform($sql, value => 1, other_value => 'abc');
$dbh->perform(-f => $sql_file_name, value => 1, other_value => 'abc');
=head2 select
Does SQL-request, pack results into iterator class. By default it uses
L<DBIx::DR::Iterator> class.
my $res = $dbh->select(-f => $sql_file_name, value => 1);
while(my $row = $res->next) {
printf "RowId: %d, RowValue: %s\n", $row->id, $row->value;
}
my $row = $row->get(15); # row 15
my $res = $dbh->select(-f => $sql_file_name,
value => 1, -hash => 'name');
while(my $row = $res->next) {
printf "RowId: %d, RowName: %s\n", $row->id, $row->name;
}
my $row = $row->get('Vasya'); # row with name eq 'Vasya'
=head2 single
Does SQL-request that returns one row. Pack results into item class.
Does SQL-request, pack results (one row) into item class. By default it
uses L<DBIx::DR::Iterator::Item|DBIx::DR::Iterator/DBIx::DR::Iterator::Item>
class.
=head1 Template language
You can use perl inside Your SQL requests:
% my $foo = 1;
% my $bar = 2;
<% my $foo_bar = $foo + $bar %>
..
% use POSIX;
% my $gid = POSIX::getgid;
There are two functions available inside perl:
=head2 quote
Replaces argument to 'B<?>', add argument value into bindlist.
You can also use shortcut 'B<=>' instead of the function.
B<Example 1>
SELECT
*
FROM
tbl
WHERE
id = <% quote $id %>
B<Result>
SELECT
*
FROM
tbl
WHERE
id = ?
and B<bindlist> will contain B<id> value.
If You use L<DBIx::DR::ByteStream> in place of string
the function will recall L<immediate> function.
B<Example 2>
SELECT
*
FROM
tbl
WHERE
id = <%= $id %>
=head2 immediate
Replaces argument to its value.
You can also use shortcut 'B<==>' instead of the function.
B<Example 1>
SELECT
*
FROM
tbl
WHERE
id = <% immediate $id %>
B<Result>
( run in 2.711 seconds using v1.01-cache-2.11-cpan-5735350b133 )