package ORDB::CPANMeta; use 5.008005; use strict; use warnings; use Params::Util 1.00 (); use ORLite::Mirror 1.15 (); our $VERSION = '0.10'; sub import { my $class = shift; my $params = Params::Util::_HASH(shift) || {}; # Pass through any params from above $params->{url} ||= 'http://svn.ali.as/db/cpanmeta.gz'; $params->{maxage} ||= 24 * 60 * 60; # One day $params->{user_version} ||= 10; # Prevent double-initialisation $class->can('orlite') or ORLite::Mirror->import( $params ); return 1; } 1; __END__ =head1 NAME ORDB::CPANMeta - An ORLite-based ORM Database API =head1 SYNOPSIS TO BE COMPLETED =head1 DESCRIPTION TO BE COMPLETED =head1 METHODS =head2 dsn my $string = Foo::Bar->dsn; The C accessor returns the dbi connection string used to connect to the SQLite database as a string. =head2 dbh my $handle = Foo::Bar->dbh; To reliably prevent potential SQLite deadlocks resulting from multiple connections in a single process, each ORLite package will only ever maintain a single connection to the database. During a transaction, this will be the same (cached) database handle. Although in most situations you should not need a direct DBI connection handle, the C method provides a method for getting a direct connection in a way that is compatible with ORLite's connection management. Please note that these connections should be short-lived, you should never hold onto a connection beyond the immediate scope. The transaction system in ORLite is specifically designed so that code using the database should never have to know whether or not it is in a transation. Because of this, you should B call the -Edisconnect method on the database handles yourself, as the handle may be that of a currently running transaction. Further, you should do your own transaction management on a handle provided by the method. In cases where there are extreme needs, and you B have to violate these connection handling rules, you should create your own completely manual DBI-Econnect call to the database, using the connect string provided by the C method. The C method returns a L object, or throws an exception on error. =head2 selectall_arrayref The C method is a direct wrapper around the equivalent L method, but applied to the appropriate locally-provided connection or transaction. It takes the same parameters and has the same return values and error behaviour. =head2 selectall_hashref The C method is a direct wrapper around the equivalent L method, but applied to the appropriate locally-provided connection or transaction. It takes the same parameters and has the same return values and error behaviour. =head2 selectcol_arrayref The C method is a direct wrapper around the equivalent L method, but applied to the appropriate locally-provided connection or transaction. It takes the same parameters and has the same return values and error behaviour. =head2 selectrow_array The C method is a direct wrapper around the equivalent L method, but applied to the appropriate locally-provided connection or transaction. It takes the same parameters and has the same return values and error behaviour. =head2 selectrow_arrayref The C method is a direct wrapper around the equivalent L method, but applied to the appropriate locally-provided connection or transaction. It takes the same parameters and has the same return values and error behaviour. =head2 selectrow_hashref The C method is a direct wrapper around the equivalent L method, but applied to the appropriate locally-provided connection or transaction. It takes the same parameters and has the same return values and error behaviour. =head2 prepare The C method is a direct wrapper around the equivalent L method, but applied to the appropriate locally-provided connection or transaction It takes the same parameters and has the same return values and error behaviour. In general though, you should try to avoid the use of your own prepared statements if possible, although this is only a recommendation and by no means prohibited. =head2 pragma # Get the user_version for the schema my $version = Foo::Bar->pragma('user_version'); The C method provides a convenient method for fetching a pragma for a datase. See the SQLite documentation for more details. =head1 SUPPORT ORDB::CPANMeta is based on L 1.22 and L 1.15. Documentation created by L 0.06. For general support please see the support section of the main project documentation. =head1 AUTHOR Adam Kennedy Eadamk@cpan.orgE =head1 COPYRIGHT Copyright 2009 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module.