Result:
found more than 823 distributions - search limited to the first 2001 files matching your query ( run in 2.013 )


DBD-Teradata

 view release on metacpan or  search on metacpan

doc/tdatdbd.html  view on Meta::CPAN


<tr bgcolor='#E9E9E9'><td align=center valign=top><b>CheckpointCallback</b></td><td align=center valign=top>Optional</td><td valign=top>None</td>
<td valign=top>Ref to a subroutine to be called when a checkpoint event occurs</td></tr>

<tr><td align=center valign=top><b>Context</b></td><td align=center valign=top>Optional</td><td valign=top>None</td>
<td valign=top>Any value the application wishes to pass thru to the callbacks; most often
a hashref with various application specific control attributes</td></tr>

<tr bgcolor='#E9E9E9'><td align=center valign=top><b>ErrorLimit</b></td><td align=center valign=top>Optional</td><td valign=top>1,000,000</td>
<td valign=top>Maximum number of errors to allow before terminating a FASTLOAD or MLOAD</td></tr>

 view all matches for this distribution


DBD-XMLSimple

 view release on metacpan or  search on metacpan

scripts/generate_index.pl  view on Meta::CPAN

						size: 12,
						weight: 'bold'
					}
				}
			}, tooltip: {
				callbacks: {
					label: function(context) {
						const raw = context.raw;
						const coverage = raw.y.toFixed(1);
						const delta = raw.delta?.toFixed(1) ?? '0.0';
						const sign = delta > 0 ? '+' : delta < 0 ? '-' : '±';

 view all matches for this distribution


DBI

 view release on metacpan or  search on metacpan

DBI.pm  view on Meta::CPAN


And the output of course would be:

  Preparing q{SELECT 1}

Because callbacks are executed I<before> the methods
they're associated with, you can modify the arguments before they're passed on
to the method call. For example, to make sure that all calls to C<prepare()>
are immediately prepared by L<DBD::Pg>, add a callback that makes sure that
the C<pg_prepare_now> attribute is always set:

DBI.pm  view on Meta::CPAN


Note that we are editing the contents of C<@_> directly. In this case we've
created the attributes hash if it's not passed to the C<prepare> call.

You can also prevent the associated method from ever executing. While a
callback executes, C<$_> holds the method name. (This allows multiple callbacks
to share the same code reference and still know what method was called.)
To prevent the method from
executing, simply C<undef $_>. For example, if you wanted to disable calls to
C<ping()>, you could do this:

DBI.pm  view on Meta::CPAN

          print "Executing ", shift->{Statement}, "\n";
      }
  };

The C<Callbacks> attribute of a database handle isn't copied to any statement
handles it creates. So setting callbacks for a statement handle requires you to
set the C<Callbacks> attribute on the statement handle yourself, as in the
example above, or use the special C<ChildCallbacks> key described below.

B<Special Keys in Callbacks Attribute>

DBI.pm  view on Meta::CPAN


The first is the C<ChildCallbacks> key. When a statement handle is created from
a database handle the C<ChildCallbacks> key of the database handle's
C<Callbacks> attribute, if any, becomes the new C<Callbacks> attribute of the
statement handle.
This allows you to define callbacks for all statement handles created from a
database handle. For example, if you wanted to count how many times C<execute>
was called in your application, you could write:

  my $exec_count = 0;
  my $dbh = DBI->connect( $dsn, $username, $auth, {

DBI.pm  view on Meta::CPAN

      print "The execute method was called $exec_count times\n";
  }

The other three special keys are C<connect_cached.new>,
C<connect_cached.connected>, and C<connect_cached.reused>. These keys define
callbacks that are called when C<connect_cached()> is called, but allow
different behaviors depending on whether a new handle is created or a handle
is returned. The callback is invoked with these arguments:
C<$dbh, $dsn, $user, $auth, $attr>.

For example, some applications uses C<connect_cached()> to connect with

DBI.pm  view on Meta::CPAN

a utility method, then it might select the same cached handle and then force
C<AutoCommit> on, forcing a commit of the transaction. See the L</connect_cached>
documentation for one way to deal with that. Here we'll describe an alternative
approach using a callback.

Because the C<connect_cached.new> and C<connect_cached.reused> callbacks are
invoked before C<connect_cached()> has applied the connect attributes, you can
use them to edit the attributes that will be applied. To prevent a cached
handle from having its transactions committed before it's returned, you can
eliminate the C<AutoCommit> attribute in a C<connect_cached.reused> callback,
like so:

DBI.pm  view on Meta::CPAN


The upshot is that new database handles are created with C<AutoCommit>
enabled, while cached database handles are left in whatever transaction state
they happened to be in when retrieved from the cache.

Note that we've also used a lexical for the callbacks hash reference. This is
because C<connect_cached()> returns a new database handle if any of the
attributes passed to is have changed. If we used an inline hash reference,
C<connect_cached()> would return a new database handle every time. Which would
rather defeat the purpose.

A more common application for callbacks is setting connection state only when
a new connection is made (by connect() or connect_cached()). Adding a callback
to the connected method (when using C<connect>) or via
C<connect_cached.connected> (when using connect_cached()>) makes this easy.
The connected() method is a no-op by default (unless you subclass the DBI and
change it). The DBI calls it to indicate that a new connection has been made

DBI.pm  view on Meta::CPAN

  sub dbh {
      my $self = shift;
      DBI->connect_cached( $dsn, $username, $auth, { Callbacks => $cb });
  }

One significant limitation with callbacks is that there can only be one per
method per handle. This means it's easy for one use of callbacks to interfere
with, or typically simply overwrite, another use of callbacks. For this reason
modules using callbacks should document the fact clearly so application authors
can tell if use of callbacks by the module will clash with use of callbacks by
the application.

You might be able to work around this issue by taking a copy of the original
callback and calling it within your own. For example:

 view all matches for this distribution


DBICx-Hooks

 view release on metacpan or  search on metacpan

lib/DBICx/Hooks.pm  view on Meta::CPAN

delete() calls on your sources.

This can be used to trigger bussiness processes after one of this
operations.

You register callbacks (even multiple callbacks) with a pair
C<Source>/C<Action>. Each callback receives a single parameter, the row
object just created/updated/just deleted.

See L<DBICx::Hooks::Registry> for extra details on the
C<dbic_hooks_registry()> function.

 view all matches for this distribution


DBIx-AutoUpgrade-NativeStrings

 view release on metacpan or  search on metacpan

lib/DBIx/AutoUpgrade/NativeStrings.pm  view on Meta::CPAN

  # return object
  bless $self, $class;
}


sub inject_callbacks {
  my ($self, $dbh, @invalid_args) = @_;

  # check input args
  $dbh->isa('DBI::db') or die '->inject_callbacks() : arg is not a DBI database handle';
  !@invalid_args       or die '->inject_callbacks() : too many args';

  # coderef to be installed as common callback for all methods. This is a closure on $self.
  my $upgrade_string_args = sub {
    # NOTES: - here there is no unpacking of @_ because DBI callbacks must work directly on @_
    #        - $_ is the name of the DBI method

    # for calls to bind_param() with an explicit bind type, some types should be left untouched (for ex. SQL_BLOB)
    return if $_ eq 'bind_param' && $_[3] && !$self->{bind_type_is_string}->($_[3]);

lib/DBIx/AutoUpgrade/NativeStrings.pm  view on Meta::CPAN


    return; # must end with an empty return (see L<DBI> documentation)
  };

  # now inject the callback for $dbh methods and for $sth methods
  my $parent_callbacks = $dbh->{Callbacks}                   //= {};
  my $child_callbacks  = $parent_callbacks->{ChildCallbacks} //= {};
  inject_callback($parent_callbacks, $_ => $upgrade_string_args)  for @{$self->{dbh_methods}};
  inject_callback($child_callbacks,  $_ => $upgrade_string_args)  for @{$self->{sth_methods}};
}


sub inject_callback {
  my ($hash, $key, $coderef) = @_;

lib/DBIx/AutoUpgrade/NativeStrings.pm  view on Meta::CPAN

  use DBIx::AutoUpgrade::NativeStrings;
  use Encode;
  
  my $injector = DBIx::AutoUpgrade::NativeStrings->new(native => 'cp1252');
  my $dbh = DBI->connect(@dbi_connection_params);
  $injector->inject_callbacks($dbh);
  
  # these strings are semantically equal, but have different internal representations
  my $str_utf8   = "il était une bergère, elle vendait ses œufs en ¥, ça paie 5¾ ‰ de mieux qu’en €",
  my $str_native = decode('cp1252', $str_utf8, Encode::LEAVE_SRC);
  

lib/DBIx/AutoUpgrade/NativeStrings.pm  view on Meta::CPAN

=back




=head2 inject_callbacks

  $injector->inject_callbacks($dbh);

Injects callbacks into the given database handle.
If that handle already has callbacks for the same methods, the system will arrange for those
other callbacks to be called I<after> all string arguments have been upgraded to utf8.


=head1 ARCHITECTURAL NOTES

=head2 Object-orientedness

lib/DBIx/AutoUpgrade/NativeStrings.pm  view on Meta::CPAN


=head2 Possible redundancies

L<DBI> does not precisely document which of its public methods call each other.
For example, one would think that C<execute()> internally calls C<bind_param()>, but this does
not seem to be the case. So, to be on the safe side, callbacks installed here make no assumptions
about string transformations performed by other callbacks. There might be some redundancies,
but it does no harm since strings are never upgraded twice.

=head2 Caveats

The C<bind_param_inout()> method is not covered -- the client program must do the proper updates

 view all matches for this distribution


DBIx-BatchChunker

 view release on metacpan or  search on metacpan

t/dbic.t  view on Meta::CPAN


        min_chunk_percent => 0.01,
        verbose           => 0,
    );

    # DBI callbacks here are the only good way to interfere with COUNT statements
    my $dbh = $batch_chunker->dbic_storage->dbh;
    $dbh->{Callbacks} = {
        ChildCallbacks => {
            execute => sub {
                my ($sth, $start, $end) = @_;

 view all matches for this distribution


DBIx-Class-CustomPrefetch

 view release on metacpan or  search on metacpan

Debian_CPANTS.txt  view on Meta::CPAN

"libmarc-crosswalk-dublincore-perl", "MARC-Crosswalk-DublinCore", "0.02", "0", "0"
"libmarc-lint-perl", "MARC-Lint", "1.44", "0", "0"
"libmarc-perl", "MARC", "1.07", "0", "0"
"libmarc-record-perl", "MARC-Record", "2.0.0", "0", "0"
"libmarc-xml-perl", "MARC-XML", "0.92", "0", "0"
"libmasonx-interp-withcallbacks-perl", "MasonX-Interp-WithCallbacks", "1.18", "0", "0"
"libmath-algebra-symbols-perl", "Math-Algebra-Symbols", "1.21", "0", "0"
"libmath-basecalc-perl", "Math-BaseCalc", "1.013", "0", "0"
"libmath-basecnv-perl", "Math-BaseCnv", "1.4.75O6Pbr", "0", "0"
"libmath-bigint-gmp-perl", "Math-BigInt-GMP", "1.24", "1", "0"
"libmath-calc-units-perl", "Math-Calc-Units", "1.07", "0", "0"

 view all matches for this distribution


DBIx-Class-DynamicDefault

 view release on metacpan or  search on metacpan

lib/DBIx/Class/DynamicDefault.pm  view on Meta::CPAN


=head2 always_update

  always_update => 1

When setting C<always_update> to 1 C<dynamic_default_on_update> callbacks will
always be invoked, even if no other columns are dirty.

=head1 AUTHOR

Florian Ragwitz E<lt>rafl@debian.orgE<gt>

 view all matches for this distribution


DBIx-Class-Fixtures

 view release on metacpan or  search on metacpan

lib/DBIx/Class/Fixtures.pm  view on Meta::CPAN

  }

  my $fixup_visitor;
  my $formatter = $schema->storage->datetime_parser;
  unless ($@ || !$formatter) {
    my %callbacks;
    if ($params->{datetime_relative_to}) {
      $callbacks{'DateTime::Duration'} = sub {
        $params->{datetime_relative_to}->clone->add_duration($_);
      };
    } else {
      $callbacks{'DateTime::Duration'} = sub {
        $formatter->format_datetime(DateTime->today->add_duration($_))
      };
    }
    $callbacks{object} ||= "visit_ref";
    $fixup_visitor = new Data::Visitor::Callback(%callbacks);
  }

  my @sorted_source_names = $self->_get_sorted_sources( $schema );
  $schema->storage->txn_do(sub {
    $schema->storage->with_deferred_fk_checks(sub {

 view all matches for this distribution


DBIx-Class-Helpers

 view release on metacpan or  search on metacpan

lib/DBIx/Class/Helper/Row/OnColumnChange.pm  view on Meta::CPAN


=back

=head1 NO SURPRISE RACE CONDITIONS

One thing that should be made totally clear is that the column change callbacks
are in effect B<< only once >> in a given update.  If you expect to be able to
do something weird like calling one of the callbacks which changes a value with
an accessor which calls a callback etc etc, you probably just need to write some
code to do that yourself.  This helper is specifically made with the aim of
reacting to changes immediately before they hit the database.

=head1 METHODS

lib/DBIx/Class/Helper/Row/OnColumnChange.pm  view on Meta::CPAN

 );

Note: the arguments passed to C<method> will be
C<< $self, $next, $old_value, $new_value >>.

Around is subtly different than the other two callbacks.  You B<must> call
C<$next> in your method or it will not work at all.  A silly example of how
this is done could be:

 sub around_change_name {
   my ($self, $next, $old, $new) = @_;

 view all matches for this distribution


DBIx-Class-Migration

 view release on metacpan or  search on metacpan

lib/Catalyst/TraitFor/Model/DBIC/Schema/FromMigration.pm  view on Meta::CPAN

=head2 install_if_needed

Accepts Bool|HashRef, Optional

If this is a true value, run the L<DBIx::Class::Migration/install_if_needed>
method.  If the value is a Hashref, we will assume it is a hashref of callbacks
as documented, and use it as an argument (after de-reffing it).

=head1 METHODS

This role exposes the following public methods

 view all matches for this distribution


DBIx-Class-Schema-Loader

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

0.07013  2011-11-17 23:12:47
        - automatically prefix database/schema to clashing monikers for
          the same table name in multischema configurations

0.07012  2011-11-09 15:16:29
        - as of 0.07011 all callbacks receive a ::Loader::Table or
          interface-compatible object instead of the table name, this object
          stringifies to the table name (RT#72260)
        - fix a bug in dynamic schema_base_class/schema_components
          implementation that ran the connection method twice on subsequent
          connects

 view all matches for this distribution


DBIx-Class

 view release on metacpan or  search on metacpan

t/storage/on_connect_call.t  view on Meta::CPAN

use DBI;
use DBICTest;
use DBICTest::Schema;
use DBIx::Class::Storage::DBI;

# !!! do not replace this with done_testing - tests reside in the callbacks
# !!! number of calls is important
use Test::More tests => 17;
# !!!
use Test::Warn;

 view all matches for this distribution


DBIx-Connector-Pool

 view release on metacpan or  search on metacpan

lib/DBIx/Connector/Pool.pm  view on Meta::CPAN


=head1 Description
 
L<DBI> is great and L<DBIx::Connector> is a nice interface with good features 
to it. But when it comes to work in some asynchronous environment like
L<AnyEvent> you have to use something another with callbacks if you don't want
to block your event loop completely waiting for data from DB. This module 
(together with L<DBIx::PgCoroAnyEvent> for PostgreSQL or some another alike) 
was developed to overcome this inconvenience. You can write your "normal" DBI
code without blocking your event loop. 

 view all matches for this distribution


DBIx-Connector

 view release on metacpan or  search on metacpan

lib/DBIx/Connector.pm  view on Meta::CPAN

won't get the transactional scoping behavior of those two methods.

If you would like to execute custom logic each time a new connection to the
database is made you can pass a sub as the C<connected> key to the
C<Callbacks> parameter. See L<DBI/Callbacks> for usage and other available
callbacks.

Other attributes may be modified by individual drivers. See the documentation
for the drivers for details:

=over

 view all matches for this distribution


DBIx-DBO2

 view release on metacpan or  search on metacpan

DBO2/Record.pm  view on Meta::CPAN


########################################################################

=head2 Hooks

Many of the methods below are labeled "Inheritable Hook." These methods allow you to register callbacks which are then invoked at specific points in each record's lifecycle. You can add these callbacks to all record classes, to a particular class, or...

To register a callback, call the install_hooks method, and pass it pairs of a hook method name, and a subroutine reference, as follows: I<callee>->install_hooks( I<methodname> => I<coderef>, ... ).

Here are a few examples to show the possibilities this provides you with:

 view all matches for this distribution


DBIx-DBSchema

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


0.35 2007-10-29 18:58:36 PDT
    - Fix minor breakage (pretty_print) resulting from Jesse's changes.
    - Update mysql driver to handle BIGSERIAL columns
    - Update Column.pm, move all mysql and Pg-specific code to DBD driver
      callbacks
    - Update Table.pm, add local_options
    - Fix mysql NULL reverse-engineering and updating code

0.34 2007-08-19 10:08:51 PDT
    - More work on update schema from Slaven Rezic <srezic@cpan.org>,

 view all matches for this distribution


DBIx-DataModel

 view release on metacpan or  search on metacpan

lib/DBIx/DataModel/Schema.pm  view on Meta::CPAN

  my ($self, $coderef) = @_;
  ref $self or $self = $self->singleton;

  $self->{transaction_dbhs}
    or croak "do_after_commit() called outside of a transaction";
  push @{$self->{after_commit_callbacks}}, $coderef;
}


sub do_transaction { 
  my ($self, $coderef, @new_dbh) = @_; 

lib/DBIx/DataModel/Schema.pm  view on Meta::CPAN

        foreach my $dbh (reverse @$transaction_dbhs) {
          try   {$dbh->rollback}
            catch {push @rollback_errs, $_};
        }
        delete $self->{transaction_dbhs};
        delete $self->{after_commit_callbacks};
        DBIx::DataModel::Schema::_Exception->throw($err, @rollback_errs);
      };
    }
  }

  # execute the after_commit callbacks
  my $callbacks = delete $self->{after_commit_callbacks} || [];
  $_->() foreach @$callbacks;

  return $in_context->{return}->();
}


 view all matches for this distribution


DBIx-FileSystem

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

	- comcol in %vdirs hash introduced: define a column that will hold
	  comments for a file
	- introduced new commands 'll' and 'ld' 
	- check length of fnamcol column againtst $LS_COL_WIDTH
	- added possibility to add custom commands
	- rmcheck and volok callbacks: added param dbh

1.07	21 july 2003
	- added missing t/use.t to MANIFEST

1.08 	11 aug 2003 

 view all matches for this distribution


DBIx-FlexibleBinding

 view release on metacpan or  search on metacpan

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN

BEGIN {
    *_is_hashref     = \&DBIx::FlexibleBinding::_is_hashref;
    *_as_list_or_ref = \&DBIx::FlexibleBinding::_as_list_or_ref;
}

use Params::Callbacks 'callbacks';
use namespace::clean;

our @ISA = 'DBI::db';

sub do
{
    my ( $callbacks, $dbh, $sth, @bind_values ) = &callbacks;
    my $result;
    unless ( ref $sth ) {
        my $attr;
        $attr = shift @bind_values
            if _is_hashref( $bind_values[0] );

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN

    }
    $result = $sth->execute( @bind_values );
    return undef
        if $sth->err;
    local $_;
    $result = $callbacks->smart_transform( $_ = $result )
        if @$callbacks;
    return $result;
}

sub prepare
{

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN

    return $sth;
}

sub getrows_arrayref
{
    my ( $callbacks, $dbh, $sth, @bind_values ) = &callbacks;
    unless ( ref $sth ) {
        my $attr;
        $attr = shift( @bind_values )
            if _is_hashref( $bind_values[0] );
        $sth = $dbh->prepare( $sth, $attr );

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN

            if $sth->err;
    }
    $sth->execute( @bind_values );
    return _as_list_or_ref( undef )
        if $sth->err;
    return $sth->getrows_arrayref( $callbacks );
}

sub getrows_hashref
{
    my ( $callbacks, $dbh, $sth, @bind_values ) = &callbacks;
    unless ( ref $sth ) {
        my $attr;
        $attr = shift( @bind_values )
            if _is_hashref( $bind_values[0] );
        $sth = $dbh->prepare( $sth, $attr );

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN

            if $sth->err;
    }
    $sth->execute( @bind_values );
    return _as_list_or_ref( undef )
        if $sth->err;
    return $sth->getrows_hashref( $callbacks );
}

sub getrow_arrayref
{
    my ( $callbacks, $dbh, $sth, @bind_values ) = &callbacks;
    unless ( ref $sth ) {
        my $attr;
        $attr = shift( @bind_values )
            if _is_hashref( $bind_values[0] );
        $sth = $dbh->prepare( $sth, $attr );

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN

    }

    $sth->execute( @bind_values );
    return undef
        if $sth->err;
    return $sth->getrow_arrayref( $callbacks );
}

sub getrow_hashref
{
    my ( $callbacks, $dbh, $sth, @bind_values ) = &callbacks;
    unless ( ref $sth ) {
        my $attr;
        $attr = shift( @bind_values )
            if _is_hashref( $bind_values[0] );
        $sth = $dbh->prepare( $sth, $attr );

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN

            if $sth->err;
    }
    $sth->execute( @bind_values );
    return undef
        if $sth->err;
    return $sth->getrow_hashref( $callbacks );
}

BEGIN {
    *getrows = \&getrows_hashref;
    *getrow  = \&getrow_hashref;

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN

    *_is_hashref     = \&DBIx::FlexibleBinding::_is_hashref;
    *_as_list_or_ref = \&DBIx::FlexibleBinding::_as_list_or_ref;
}

use List::MoreUtils   ( 'any' );
use Params::Callbacks ( 'callbacks' );
use namespace::clean;
use message << 'EOF';
ERR_EXP_AHR         Expected a reference to a HASH or ARRAY
ERR_MISSING_BIND_ID Binding identifier is missing
ERR_BAD_BIND_ID     Bad binding identifier (%s)

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN

    return $rows;
}

sub iterate
{
    my ( $callbacks, $sth, @bind_values ) = &callbacks;
    my $rows = $sth->execute( @bind_values );
    return $rows unless defined $rows;
    my $iter_fn = sub { $sth->getrow( $callbacks ) };
    return bless( $iter_fn, 'DBIx::FlexibleBinding::Iterator' );
}

sub getrows_arrayref
{
    my ( $callbacks, $sth, @args ) = &callbacks;
    unless ( $sth->{Active} ) {
        $sth->execute( @args );
        return _as_list_or_ref( undef )
            if $sth->err;
    }
    my $result = $sth->fetchall_arrayref;
    return _as_list_or_ref( $result )
        if $sth->err or not defined $result;
    local $_;
    $result = [ map { $callbacks->transform( $_ ) } @$result ]
        if @$callbacks;
    return _as_list_or_ref( $result );
}

sub getrows_hashref
{
    my ( $callbacks, $sth, @args ) = &callbacks;
    unless ( $sth->{Active} ) {
        $sth->execute( @args );
        return _as_list_or_ref( undef )
            if $sth->err;
    }
    my $result = $sth->fetchall_arrayref( {} );
    return _as_list_or_ref( $result )
        if $sth->err or not defined $result;
    local $_;
    $result = [ map { $callbacks->transform( $_ ) } @$result ]
        if @$callbacks;
    return _as_list_or_ref( $result );
}

sub getrow_arrayref
{
    my ( $callbacks, $sth, @args ) = &callbacks;
    unless ( $sth->{Active} ) {
        $sth->execute( @args );
        return undef
            if $sth->err;
    }
    my $result = $sth->fetchrow_arrayref;
    return $result
        if $sth->err or not defined $result;
    local $_;
    $result = [@$result];
    $result = $callbacks->smart_transform( $_ = $result )
        if @$callbacks;
    return $result;
}

sub getrow_hashref
{
    my ( $callbacks, $sth, @args ) = &callbacks;
    unless ( $sth->{Active} ) {
        $sth->execute( @args );
        return undef
            if $sth->err;
    }
    my $result = $sth->fetchrow_hashref;
    return $result
        if $sth->err or not defined $result;
    local $_;
    $result = $callbacks->smart_transform( $_ = $result )
        if @$callbacks;
    return $result;
}

BEGIN {
    *getrows = \&getrows_hashref;

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN


package    # Hide from PAUSE
    DBIx::FlexibleBinding::Iterator;
our $VERSION = '2.0.4'; # VERSION

use Params::Callbacks ( 'callbacks' );
use namespace::clean;

sub for_each
{
    my ( $callbacks, $iter ) = &callbacks;
    my @results;
    local $_;
    while ( my @items = $iter->() ) {
        last if @items == 1 and not defined $items[0];
        push @results, map { $callbacks->transform( $_ ) } @items;
    }
    return wantarray ? @results : \@results;
}

1;

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN

rows affected or undef on error. A return value of -1 means the number of rows
is not known, not applicable, or not available. When no rows have been affected
this method continues the C<DBI> tradition of returning C<0E0> on successful
execution and C<undef> on failure.

The C<do> method accepts optional callbacks for further processing of the result.

The C<do> implementation provided by this module allows for some minor
deviations in usage over the standard C<DBI> implementation. In spite
of this, the new method may be used just like the original.

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN

    @results = $dbh->getrows_arrayref($statement_handle, @bind_values);

Prepares (if necessary) and executes a single statement with the specified data
bindings and fetches the result set as an array of array references.

The C<getrows_arrayref> method accepts optional callbacks for further processing
of the results by the caller.

B<Examples>

=over

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN


=item 3. Re-use a prepared statement, execute it then return modified results as a
reference:

We'll use the query from Example 1 but have the results returned as a list
for further processing by a caller who will be using callbacks to modify those
results.

    $sth = $dbh->prepare($sql);

    $systems = $dbh->getrows_arrayref($sql, minimum_security => 1.0, callback {

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN

    @results = $dbh->getrows_hashref($statement_handle, @bind_values);

Prepares (if necessary) and executes a single statement with the specified data
bindings and fetches the result set as an array of hash references.

The C<getrows_hashref> method accepts optional callbacks for further processing
of the results by the caller.

B<Examples>

=over

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN


=item 3. Re-use a prepared statement, execute it then return modified results as a
reference:

We'll use the query from Example 1 but have the results returned as a list
for further processing by a caller who will be using callbacks to modify those
results.

    $sth = $dbh->prepare($sql);

    $systems = $dbh->getrows_hashref($sql, minimum_security => 1.0, callback {

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN

Alias for C<getrows_hashref>.

If array references are preferred, have the symbol table glob point alias the 
C<getrows_arrayref> method.

The C<getrows> method accepts optional callbacks for further processing
of the results by the caller.

=head2 getrow_arrayref I<(database handles)>

    $result = $dbh->getrow_arrayref($statement_string, @bind_values);

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN

    $result = $dbh->getrow_arrayref($statement_handle, @bind_values);

Prepares (if necessary) and executes a single statement with the specified data
bindings and fetches the first row as an array reference.

The C<getrow_arrayref> method accepts optional callbacks for further processing
of the result by the caller.

=head2 getrow_hashref I<(database handles)>

    $result = $dbh->getrow_hashref($statement_string, @bind_values);

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN

    $result = $dbh->getrow_hashref($statement_handle, @bind_values);

Prepares (if necessary) and executes a single statement with the specified data
bindings and fetches the first row as a hash reference.

The C<getrow_hashref> method accepts optional callbacks for further processing
of the result by the caller.

=head2 getrow I<(database handles)>

    $result = $dbh->getrow($statement_string, @bind_values);

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN

Alias for C<getrow_hashref>.

If array references are preferred, have the symbol table glob point alias the 
C<getrows_arrayref> method.

The C<getrow> method accepts optional callbacks for further processing
of the result by the caller.

=head1 STATEMENT HANDLE METHODS

=head2 bind_param

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN


B<Examples>

=over

=item 1. Using an iterator and callbacks to process the result set:

    use strict;
    use warnings;

    use DBIx::FlexibleBinding -subs => [ 'TestDB' ];

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN


In this example, we're traversing the result set using an iterator. As we iterate
through the result set, a callback is applied to each row and we're left with
an array of transformed rows.

=item 2. Using an iterator's C<for_each> method and callbacks to process the
result set:

    use strict;
    use warnings;

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN

    $results = $sth->getrows_arrayref();
    @results = $sth->getrows_arrayref();

Fetches the entire result set as an array of array references.

The C<getrows_arrayref> method accepts optional callbacks for further processing
of the results by the caller.

=head2 getrows_hashref I<(database handles)>

    $results = $sth->getrows_hashref();
    @results = $sth->getrows_hashref();

Fetches the entire result set as an array of hash references.

The C<getrows_hashref> method accepts optional callbacks for further processing
of the results by the caller.

=head2 getrows I<(database handles)>

    $results = $sth->getrows();

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN

Alias for C<getrows_hashref>.

If array references are preferred, have the symbol table glob point alias the 
C<getrows_arrayref> method.

The C<getrows> method accepts optional callbacks for further processing
of the results by the caller.

=head2 getrow_arrayref I<(database handles)>

    $result = $sth->getrow_arrayref();

Fetches the next row as an array reference. Returns C<undef> if there are no more
rows available.

The C<getrow_arrayref> method accepts optional callbacks for further processing
of the result by the caller.

=head2 getrow_hashref I<(database handles)>

    $result = $sth->getrow_hashref();

Fetches the next row as a hash reference. Returns C<undef> if there are no more
rows available.

The C<getrow_hashref> method accepts optional callbacks for further processing
of the result by the caller.

=head2 getrow I<(database handles)>

    $result = $sth->getrow();

lib/DBIx/FlexibleBinding.pm  view on Meta::CPAN

Alias for C<getrow_hashref>.

If array references are preferred, have the symbol table glob point alias the 
C<getrows_arrayref> method.

The C<getrow> method accepts optional callbacks for further processing
of the result by the caller.

=head1 EXPORTS

The following symbols are exported by default:

=head2 callback

To enable the namespace using this module to take advantage of the callbacks,
which are one of its main features, without the unnecessary burden of also
including the module that provides the feature I<(see L<Params::Callbacks> for
more detailed information)>.

=head1 SEE ALSO

 view all matches for this distribution


DBIx-HTMLinterface

 view release on metacpan or  search on metacpan

HTMLinterface.pm  view on Meta::CPAN


=over 4

=item Future Additions

In a later version, callbacks to print table cells, start and finish tables, 
print form fields, print back links and add user defined form parameters to 
allow state keeping such as password protection etc.

=item B<set_printheader>

 view all matches for this distribution


DBIx-ObjectMapper

 view release on metacpan or  search on metacpan

lib/DBIx/ObjectMapper/Log.pm  view on Meta::CPAN

                'Screen',
                min_level => $min_level,
                newline => 1,
            ]
        ],
        callbacks => sub {
            my %param = @_;
            return sprintf("[%s] %s", $param{level}, $param{message});
        }
    );
};

 view all matches for this distribution


DBIx-OnlineDDL

 view release on metacpan or  search on metacpan

lib/DBIx/OnlineDDL.pm  view on Meta::CPAN

        # Make sure the basic settings are sane
        $dbi_attrs->{AutoCommit} = 1;
        $dbi_attrs->{RaiseError} = 1;

        # Add the DBI callback
        my $callbacks  = $dbi_attrs->{Callbacks} //= {};
        my $package_re = quotemeta(__PACKAGE__.'::_dbi_connected_callback');

        my $ref = defined $callbacks->{connected} && ref $callbacks->{connected};
        unless ($callbacks->{connected}) {
            $callbacks->{connected} = set_subname '_dbi_connected_callback' => sub {
                shift->do($_) for @stmts;
                return;
            };
        }
        elsif (!$ref || $ref ne 'CODE') {
            die "Illegal reftype $ref for connected DBI Callback!";
        }
        elsif (subname($callbacks->{connected}) =~ /^$package_re/) {  # allow for *_wrapped below
            # This is one of our callbacks; leave it alone!
        }
        else {
            # This is somebody else's callback; wrap around it
            my $old_coderef = $callbacks->{connected};
            $callbacks->{connected} = set_subname '_dbi_connected_callback_wrapped' => sub {
                my $h = shift;
                $old_coderef->($h);
                $h->do($_) for @stmts;
                return;
            };

 view all matches for this distribution


DBIx-Oracle-UpgradeUtf8

 view release on metacpan or  search on metacpan

lib/DBIx/Oracle/UpgradeUtf8.pm  view on Meta::CPAN

  # return object
  bless $self, $class;
}


sub inject_callbacks {
  my ($self, $dbh, @invalid_args) = @_;

  # check input args
  $dbh->isa('DBI::db') or die '->inject_callbacks() : arg is not a database handle';
  !@invalid_args       or die '->inject_callbacks() : too many args';

  # coderef to be installed as common callback for all methods. This is a closure on $debug.
  my $debug = $self->{debug};                 # Copy for easier reference. The coderef will be a closure on $debug.
  my $upgrade_string_args = sub {
    $debug->("$_ callback") if $debug;        # Note: $_ is the method name

lib/DBIx/Oracle/UpgradeUtf8.pm  view on Meta::CPAN

    }

    return; # must end with an empty return (see L<DBI> documentation)
  };

  # inject callbacks for $dbh methods and for $sth methods
  my $parent_callbacks = $dbh->{Callbacks}                   //= {};
  my $child_callbacks  = $parent_callbacks->{ChildCallbacks} //= {};
  inject_callback($parent_callbacks, $_ => $upgrade_string_args)  for @{$self->{dbh_methods}};
  inject_callback($child_callbacks,  $_ => $upgrade_string_args)  for @{$self->{sth_methods}};
}


sub inject_callback {
  my ($hash, $key, $coderef) = @_;

 view all matches for this distribution


DBIx-Poggy

 view release on metacpan or  search on metacpan

lib/DBIx/Poggy.pm  view on Meta::CPAN


    $cv->recv;

=head1 DESCRIPTION

"Async" postgres as much as L<DBD::Pg> allows with L<Promises> instead of callbacks.

You get DBI interface you used to that returns promises, connections pool, queries
queuing and support of transactions.

=head2 Why pool?

 view all matches for this distribution


DBIx-QuickORM

 view release on metacpan or  search on metacpan

lib/DBIx/QuickORM/Connection.pm  view on Meta::CPAN

        on_fail       => $params{on_fail},
        on_success    => $params{on_success},
        on_completion => $params{on_completion},
    );

    $self->_txn_attach_relative_callbacks($txn, \%params);

    push @{$txns} => $txn;
    weaken($txns->[-1]);

    my $finalize = $self->_txn_finalizer($sp);

lib/DBIx/QuickORM/Connection.pm  view on Meta::CPAN

    return undef;
}

=pod

=item $con->_txn_attach_relative_callbacks($txn, \%params)

Attaches C<on_parent_*> callbacks to the current innermost transaction and
C<on_root_*> callbacks to the outermost one. Called before C<$txn> is pushed
onto the stack.

=cut

sub _txn_attach_relative_callbacks {
    my $self = shift;
    my ($txn, $params) = @_;

    my $txns = $self->{+TRANSACTIONS};

    # With an empty stack the new txn is its own root, but it has no parent;
    # on_parent_* callbacks are documented as no-ops in that case. Stack
    # entries are weak references, so check definedness before using them.
    my $parent = @$txns ? $txns->[-1] : undef;
    my $root   = @$txns ? $txns->[0]  : $txn;

    if ($parent) {

lib/DBIx/QuickORM/Connection.pm  view on Meta::CPAN


=item $cb = $con->_txn_finalizer($savepoint_or_undef)

Builds the one-shot finalize callback that pops the transaction off the
stack, commits or rolls back (savepoint or real transaction), and fires the
transaction's callbacks via C<terminate>.

=cut

sub _txn_finalizer {
    my $self = shift;

 view all matches for this distribution


DBIx-RetryOverDisconnects

 view release on metacpan or  search on metacpan

lib/DBIx/RetryOverDisconnects.pm  view on Meta::CPAN


=head2 set_callback

    $dbh->set_callback(afterReconnect => $code_ref);

Set callbacks for some events. Currently only afterReconnect is supported.
It is called after every successful reconnect to database.

=cut

sub set_callback {
    my ($self, %callbacks) = @_;
    my $old = $self->{PRIV()}->{callback} || {};
    $self->{PRIV()}->{callback} = {%$old, %callbacks};
    return;
}

sub exc_conn_trans {
    my $self = shift;

 view all matches for this distribution


DBIx-Roles

 view release on metacpan or  search on metacpan

Roles.pm  view on Meta::CPAN


C<DBIx::Roles::Default> - not a module on its own, but a package that is
always imported, and need not to be imported explicitly. Implements actual calls
to DBI handle.

L<DBIx::Roles::Hook> - Exports callbacks to override DBI calls.

L<DBIx::Roles::InlineArray> - Flattens arrays passed as parameters to DBI calls into strings.

L<DBIx::Roles::RaiseError> - Change defaults to C<< RaiseError => 1 >>

 view all matches for this distribution


DBIx-SQLEngine

 view release on metacpan or  search on metacpan

SQLEngine/Record/Hooks.pm  view on Meta::CPAN

  
  package My::Record;
  use DBIx::SQLEngine::Record::Class '-isasubclass', 'Hooks';  
  My::Record->table( $sqldb->table($table_name) );

B<Hooks:> Register subs for callbacks.

  DBIx::SQLEngine::Record::Hooks->install_hooks( 
    post_new    => sub { warn "Record $_[0] created" },
    post_fetch  => sub { warn "Record $_[0] loaded" },
    post_insert => sub { warn "Record $_[0] inserted" },

SQLEngine/Record/Hooks.pm  view on Meta::CPAN


########################################################################

=head1 HOOKS INTERFACE

Many of the methods below are labeled "Inheritable Hook." These methods allow you to register callbacks which are then invoked at specific points in each record's lifecycle. You can add these callbacks to all record classes, to a particular class, or...

These hooks act like the triggers supported by some databases; you can ensure that every time a record is updated in a specific table, certain other actions occur automatically.

To register a callback, call the install_hooks method, and pass it pairs of a hook method name, and a subroutine reference, as follows: I<callee>->install_hooks( I<methodname> => I<coderef>, ... ).

SQLEngine/Record/Hooks.pm  view on Meta::CPAN

=item install_hooks()

  $classname->install_hooks( $hook_name => \&my_sub, ... )
  $record->install_hooks( $hook_name => \&my_sub, ... )

Registers one or more callbacks. Accepts pairs of a hook method name, and a subroutine reference. 

For more about the implementation of the Hook mechanism, see L<Class::MakeMethods::Composite::Inheritable>.

=back

 view all matches for this distribution


DBIx-Squirrel

 view release on metacpan or  search on metacpan

lib/DBIx/Squirrel/it.pm  view on Meta::CPAN

);
use Sub::Name 'subname';
use DBIx::Squirrel::util qw(
    cluckf
    confessf
    callbacks_args
);
use namespace::clean;

use constant E_BAD_STH   => 'Expected a statement handle object';
use constant E_BAD_SLICE => 'Slice must be a reference to an ARRAY or HASH';

lib/DBIx/Squirrel/it.pm  view on Meta::CPAN


=cut

sub new {
    my $class = ref $_[0] ? ref shift : shift;
    my( $transforms, $sth, @bind_values ) = callbacks_args(@_);
    confessf E_BAD_STH unless UNIVERSAL::isa( $sth, 'DBIx::Squirrel::st' );
    my $self = bless {}, $class;
    $self->_private_state( {
        sth                 => $sth,
        bind_values_initial => [@bind_values],

lib/DBIx/Squirrel/it.pm  view on Meta::CPAN

    *slice_buffer_size = subname( slice_buffer_size => \&slice_cache_size );
}

sub start {
    my( $attr,       $self )        = shift->_private_state;
    my( $transforms, @bind_values ) = callbacks_args(@_);
    if ( @{$transforms} ) {
        $attr->{transforms} = [ @{ $attr->{transforms_initial} }, @{$transforms} ];
    }
    else {
        unless ( defined $attr->{transforms} && @{ $attr->{transforms} } ) {

 view all matches for this distribution


( run in 2.013 seconds using v1.01-cache-2.11-cpan-cdf2f3d4e48 )