.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "AnyEvent::DBD::Pg 3pm" .TH AnyEvent::DBD::Pg 3pm "2022-06-05" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" AnyEvent::DBD::Pg \- AnyEvent interface to DBD::Pg's async interface .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use AnyEvent::DBD::Pg; \& \& my $adb = AnyEvent::DBD::Pg\->new(\*(Aqdbi:Pg:dbname=test\*(Aq, user => \*(Aqpass\*(Aq, { \& pg_enable_utf8 => 1, \& pg_server_prepare => 0, \& quote_char => \*(Aq"\*(Aq, \& name_sep => ".", \& }, debug => 1); \& \& $adb\->queue_size( 4 ); \& $adb\->debug( 1 ); \& \& $adb\->connect; \& \& $adb\->selectcol_arrayref("select pg_sleep( 0.1 ), 1", { Columns => [ 1 ] }, sub { \& my $rc = shift or return warn; \& my $res = shift; \& warn "Got <$adb\->{qd}> = $rc / @{$res}"; \& $adb\->selectrow_hashref("select data,* from tx limit 2", {}, sub { \& my $rc = shift or return warn; \& warn "Got $adb\->{qd} = $rc [@_]"; \& }); \& }); \& \& $adb\->execute("update tx set data = data;",sub { \& my $rc = shift or return warn; \& warn "Got exec: $rc"; \& #my $st = shift; \& #$st\->finish; \& }); \& \& $adb\->execute("select from 1",sub { \& shift or return warn; \& warn "Got $adb\->{qd} = @_"; \& }); \& \& $adb\->selectrow_array("select pg_sleep( 0.1 ), 2", {}, sub { \& shift or return warn; \& warn "Got $adb\->{qd} = [@_]"; \& $adb\->selectrow_hashref("select * from tx limit 1", {}, sub { \& warn "Got $adb\->{qd} = [@_]"; \& $adb\->execute("select * from tx", sub { \& my $rc = shift or return warn; \& my $st = shift; \& while(my $row = $st\->fetchrow_hashref) { warn "$row\->{id}"; } \& $st\->finish; \& exit; \& }); \& }); \& }); \& AE::cv\->recv; .Ve .SH "METHODS" .IX Header "METHODS" .IP "\fBconnect()\fR" 4 .IX Item "connect()" Establish connection to database .ie n .IP "selectrow_array( $query, [\e%args], $cb\->( $rc, ... ))" 4 .el .IP "selectrow_array( \f(CW$query\fR, [\e%args], \f(CW$cb\fR\->( \f(CW$rc\fR, ... ))" 4 .IX Item "selectrow_array( $query, [%args], $cb->( $rc, ... ))" Execute \s-1PG_ASYNC\s0 prepare, than push result of \f(CW\*(C`fetchrow_array\*(C'\fR into callback .ie n .IP "selectrow_arrayref( $query, [\e%args], $cb\->( $rc, \e@row ))" 4 .el .IP "selectrow_arrayref( \f(CW$query\fR, [\e%args], \f(CW$cb\fR\->( \f(CW$rc\fR, \e@row ))" 4 .IX Item "selectrow_arrayref( $query, [%args], $cb->( $rc, @row ))" Execute \s-1PG_ASYNC\s0 prepare, than push result of \f(CW\*(C`fetchrow_arrayref\*(C'\fR into callback .ie n .IP "selectrow_hashref( $query, [\e%args], $cb\->( $rc, \e%row ))" 4 .el .IP "selectrow_hashref( \f(CW$query\fR, [\e%args], \f(CW$cb\fR\->( \f(CW$rc\fR, \e%row ))" 4 .IX Item "selectrow_hashref( $query, [%args], $cb->( $rc, %row ))" Execute \s-1PG_ASYNC\s0 prepare, than push result of \f(CW\*(C`fetchrow_hashref\*(C'\fR into callback .ie n .IP "selectall_arrayref( $query, [\e%args], $cb\->( $rc, \e@rows ))" 4 .el .IP "selectall_arrayref( \f(CW$query\fR, [\e%args], \f(CW$cb\fR\->( \f(CW$rc\fR, \e@rows ))" 4 .IX Item "selectall_arrayref( $query, [%args], $cb->( $rc, @rows ))" Execute \s-1PG_ASYNC\s0 prepare, than push result of \f(CW\*(C`fetchall_arrayref\*(C'\fR into callback .ie n .IP "selectall_hashref( $query, [\e%args], $cb\->( $rc, \e@rows ))" 4 .el .IP "selectall_hashref( \f(CW$query\fR, [\e%args], \f(CW$cb\fR\->( \f(CW$rc\fR, \e@rows ))" 4 .IX Item "selectall_hashref( $query, [%args], $cb->( $rc, @rows ))" Execute \s-1PG_ASYNC\s0 prepare, than push result of \f(CW\*(C`fetchall_hashref\*(C'\fR into callback .ie n .IP "selectcol_arrayref( $query, { Columns => [...], ... }, $cb\->( $rc, \e@rows ))" 4 .el .IP "selectcol_arrayref( \f(CW$query\fR, { Columns => [...], ... }, \f(CW$cb\fR\->( \f(CW$rc\fR, \e@rows ))" 4 .IX Item "selectcol_arrayref( $query, { Columns => [...], ... }, $cb->( $rc, @rows ))" Execute \s-1PG_ASYNC\s0 prepare, than push result of \f(CW\*(C`fetchall_hashref($args{Columns})\*(C'\fR into callback .ie n .IP "execute( $query, [\e%args], $cb\->( $rc, $sth ))" 4 .el .IP "execute( \f(CW$query\fR, [\e%args], \f(CW$cb\fR\->( \f(CW$rc\fR, \f(CW$sth\fR ))" 4 .IX Item "execute( $query, [%args], $cb->( $rc, $sth ))" Execute \s-1PG_ASYNC\s0 prepare, than invoke callback, pushing resulting sth to it. .Sp \&\fBPlease, note\fR: result already passed as first argument .SH "AUTHOR" .IX Header "AUTHOR" Mons Anderson, \f(CW\*(C`\*(C'\fR .SH "LICENSE AND COPYRIGHT" .IX Header "LICENSE AND COPYRIGHT" Copyright 2010 Mons Anderson. .PP This program is free software; you can redistribute it and/or modify it under the terms of either: the \s-1GNU\s0 General Public License as published by the Free Software Foundation; or the Artistic License.