<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME

    AnyEvent::DBI::MySQL - Asynchronous MySQL queries

VERSION

    This document describes AnyEvent::DBI::MySQL version v1.0.6

SYNOPSIS

        use AnyEvent::DBI::MySQL;
    
        # get cached but not in use $dbh
        $dbh = AnyEvent::DBI::MySQL-&gt;connect(窶ｦ);
    
        # async
        $dbh-&gt;do(窶ｦ,                 sub { my ($rv, $dbh) = @_; 窶ｦ });
        $sth = $dbh-&gt;prepare(窶ｦ);
        $sth-&gt;execute(窶ｦ,            sub { my ($rv, $sth) = @_; 窶ｦ });
        $dbh-&gt;selectall_arrayref(窶ｦ, sub { my ($ary_ref)  = @_; 窶ｦ });
        $dbh-&gt;selectall_hashref(窶ｦ,  sub { my ($hash_ref) = @_; 窶ｦ });
        $dbh-&gt;selectcol_arrayref(窶ｦ, sub { my ($ary_ref)  = @_; 窶ｦ });
        $dbh-&gt;selectrow_array(窶ｦ,    sub { my (@row_ary)  = @_; 窶ｦ });
        $dbh-&gt;selectrow_arrayref(窶ｦ, sub { my ($ary_ref)  = @_; 窶ｦ });
        $dbh-&gt;selectrow_hashref(窶ｦ,  sub { my ($hash_ref) = @_; 窶ｦ });
    
        # sync
        $rv = $dbh-&gt;do('窶ｦ');
        $dbh-&gt;do('窶ｦ', {async=&gt;0}, sub { my ($rv, $dbh) = @_; 窶ｦ });

DESCRIPTION

    This module is an AnyEvent user, you need to make sure that you use and
    run a supported event loop.

    This module implements asynchronous MySQL queries using "ASYNCHRONOUS
    QUERIES" in DBD::mysql feature. Unlike AnyEvent::DBI it doesn't spawn
    any processes.

    You shouldn't use {RaiseError=&gt;1} with this module and should check
    returned values in your callback to detect errors. This is because with
    {RaiseError=&gt;1} exception will be thrown instead of calling your
    callback function, which isn't what you want in most cases.

INTERFACE

    The API is trivial: use it just like usual DBI, but instead of
    expecting return value from functions which may block add one extra
    parameter: callback. That callback will be executed with usual returned
    value of used method in params (only exception is extra $dbh/$sth param
    in do() and execute() for convenience).

 SYNCHRONOUS QUERIES

    In most cases to make usual synchronous query it's enough to don't
    provide callback - use standard DBI params and it will work just like
    usual DBI. Only exception is prepare()/execute() pair: you should use
    {async=&gt;0} attribute for prepare() to have synchronous execute().

    For convenience, you can quickly turn asynchronous query to synchronous
    by adding {async=&gt;0} attribute - you don't have to rewrite code to
    remove callback function. In this case your callback will be called
    immediately after executing this synchronous query.

    connect(窶ｦ)

      DBD::mysql support only single asynchronous query per MySQL
      connection. To make it easier to overcome this limitation provided
      connect() constructor work using DBI-&gt;connect_cached() under the
      hood, but it reuse only inactive $dbh - i.e. one which you didn't use
      anymore. So, connect() guarantee to not return $dbh which is already
      in use in your code. For example, in FastCGI or Mojolicious app you
      can safely use connect() to get own $dbh per each incoming
      connection; after you send response and close this connection that
      $dbh should automatically go out of scope and become inactive (you
      can force this by $dbh=undef;); after that this $dbh may be returned
      by connect() when handling next incoming request. As result you
      should automatically get a pool of connected $dbh which size should
      match peak amount of simultaneously handled CGI requests. You can
      flush that $dbh cache as documented by DBI at any time.

      NOTE: To implement this caching behavior this module catch DESTROY()
      for $dbh and instead of destroying it (and calling
      $dbh-&gt;disconnect()) make it available for next connect() call in
      cache. So, if you need to call $dbh-&gt;disconnect() - do it manually
      and don't expect it to happens automatically on $dbh DESTROY(), like
      it work in DBI.

      Also, usual limitations for cached connections apply as documented by
      DBI (read: don't change $dbh configuration).

    $dbh-&gt;do(窶ｦ, sub { my ($rv, $dbh) = @_; 窶ｦ });

    $sth-&gt;execute(窶ｦ, sub { my ($rv, $sth) = @_; 窶ｦ });

    $dbh-&gt;selectall_arrayref(窶ｦ, sub { my ($ary_ref) = @_; 窶ｦ });

    $dbh-&gt;selectall_hashref(窶ｦ, sub { my ($hash_ref) = @_; 窶ｦ });

    $dbh-&gt;selectcol_arrayref(窶ｦ, sub { my ($ary_ref) = @_; 窶ｦ });

    $dbh-&gt;selectrow_array(窶ｦ, sub { my (@row_ary) = @_; 窶ｦ });

    $dbh-&gt;selectrow_arrayref(窶ｦ, sub { my ($ary_ref) = @_; 窶ｦ });

    $dbh-&gt;selectrow_hashref(窶ｦ, sub { my ($hash_ref) = @_; 窶ｦ });

BUGS AND LIMITATIONS

    No bugs have been reported.

    These DBI methods not supported yet (i.e. they work as usually - in
    blocking mode), mostly because they internally run several queries and
    should be completely rewritten to support non-blocking mode.

    NOTE: You have to provide {async=&gt;0} attribute to prepare() before
    using execute_array() or execute_for_fetch().

        $sth-&gt;execute_array(窶ｦ)
        $sth-&gt;execute_for_fetch(窶ｦ)
        $dbh-&gt;table_info(窶ｦ)
        $dbh-&gt;column_info(窶ｦ)
        $dbh-&gt;primary_key_info(窶ｦ)
        $dbh-&gt;foreign_key_info(窶ｦ)
        $dbh-&gt;statistics_info(窶ｦ)
        $dbh-&gt;primary_key(窶ｦ)
        $dbh-&gt;tables(窶ｦ)

SEE ALSO

    AnyEvent, DBI, AnyEvent::DBI

SUPPORT

 Bugs / Feature Requests

    Please report any bugs or feature requests through the issue tracker at
    https://github.com/powerman/perl-AnyEvent-DBI-MySQL/issues. You will be
    notified automatically of any progress on your issue.

 Source Code

    This is open source software. The code repository is available for
    public review and contribution under the terms of the license. Feel
    free to fork the repository and submit pull requests.

    https://github.com/powerman/perl-AnyEvent-DBI-MySQL

        git clone https://github.com/powerman/perl-AnyEvent-DBI-MySQL.git

 Resources

      * MetaCPAN Search

      https://metacpan.org/search?q=AnyEvent-DBI-MySQL

      * CPAN Ratings

      http://cpanratings.perl.org/dist/AnyEvent-DBI-MySQL

      * AnnoCPAN: Annotated CPAN documentation

      http://annocpan.org/dist/AnyEvent-DBI-MySQL

      * CPAN Testers Matrix

      http://matrix.cpantesters.org/?dist=AnyEvent-DBI-MySQL

      * CPANTS: A CPAN Testing Service (Kwalitee)

      http://cpants.cpanauthors.org/dist/AnyEvent-DBI-MySQL

AUTHOR

    Alex Efros &lt;powerman@cpan.org&gt;

COPYRIGHT AND LICENSE

    This software is Copyright (c) 2013-2014 by Alex Efros
    &lt;powerman@cpan.org&gt;.

    This is free software, licensed under:

      The MIT (X11) License

</pre></body></html>