Acrux-DBI
view release on metacpan or search on metacpan
lib/Acrux/DBI.pm view on Meta::CPAN
=head2 port
my $port = $dbi->port;
This is the L<Mojo::URL/port> that will be used for generating the connection DSN
Default: none
=head2 query
my $res = $dbi->query('select * from test');
my $res = $dbi->query('insert into test values (?, ?)', @values);
Execute a blocking statement and return a L<Acrux::DBI::Res> object with the results.
You can also append a 'bind_callback' to perform binding value manually:
my $res = $dbi->query('insert into test values (?, ?)', {
bind_callback => sub {
my $sth = shift;
$sth->bind_param( ... );
}
lib/Acrux/DBI/Res.pm view on Meta::CPAN
See also L<CTK::DBI/recordh>
=head2 hashed_by
my $hash = $res->hashed_by( $key_field );
my $hash = $res->hashed_by( 'id' );
This method returns a reference to a hash containing a key for each distinct
value of the C<$key_field> column that was fetched.
For each key the corresponding value is a reference to a hash containing
all the selected columns and their values, as returned by C<fetchrow_hashref()>
For example:
my $hash = $res->hashed_by( 'id' );
# {
# 1 => {
# 'id' => 1,
# 'name' => 'foo'
# },
t/03-connect.t view on Meta::CPAN
#is($dbi->driver, 'postgres', 'Driver (scheme) is postgres');
#is($dbi->host, 'localhost', 'Host is localhost');
#is($dbi->port, '', 'Port is null');
#is($dbi->userinfo, 'foo:pass', 'Userinfo is foo:pass');
#is($dbi->password, 'pass', 'Password is pass');
#is($dbi->database, 'mydb', 'Password is mydb');
#is($dbi->dsn, 'DBI:Pg:dbname=mydb;host=localhost', 'DSN is DBI:Pg:dbname=mydb;host=localhost');
#note explain {(DBI->installed_drivers)};
#my $res = $dbi->query('select * from monm');
#ok($res, 'select * from monm') or diag $dbi->error;
#note explain $res;
#note explain $res->array;
#note explain $res->arrays;
#note explain $res->collection_list;
#note explain $res->columns;
#note explain $res->hash;
#note explain $res->hashes;
#note explain $res->collection;
#note $res->rows;
#note $res->text;
( run in 1.051 second using v1.01-cache-2.11-cpan-49f99fa48dc )