Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ap/dbix-simple-interpol
monkey-patch DBIx::Simple to use SQL::Interpol
https://github.com/ap/dbix-simple-interpol
dbix perl sql
Last synced: 4 days ago
JSON representation
monkey-patch DBIx::Simple to use SQL::Interpol
- Host: GitHub
- URL: https://github.com/ap/dbix-simple-interpol
- Owner: ap
- Created: 2014-12-30T05:11:49.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2022-09-01T22:06:29.000Z (over 2 years ago)
- Last Synced: 2024-11-06T03:03:55.669Z (about 2 months ago)
- Topics: dbix, perl, sql
- Language: Perl
- Homepage: https://metacpan.org/release/DBIx-Simple-Interpol
- Size: 10.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.pod
- Changelog: Changes
Awesome Lists containing this project
README
use 5.006; use strict; use warnings;
package DBIx::Simple::Interpol;
our $VERSION = '1.007';
use SQL::Interpol ();
use DBIx::Simple ();sub import {
shift;
my $prelude = sprintf qq'package %s;\n#line %d "%s"\n', ( caller )[0,2,1];
my $sub = eval qq{ sub { $prelude SQL::Interpol->import(\@_) } };
&$sub;
}sub iquery {
my $self = shift;
my $p = SQL::Interpol::Parser->new;
my $sql = $p->parse( @_ );
$self->query( $sql, @{ $p->bind } );
}die 'Cannot find method to patch' if not DBIx::Simple->can( 'iquery' );
do { no warnings 'redefine'; *DBIx::Simple::iquery = \&iquery };
__END__
=pod
=encoding UTF-8
=head1 NAME
DBIx::Simple::Interpol - monkey-patch DBIx::Simple to use SQL::Interpol
=head1 SYNOPSIS
use DBIx::Simple::Interpol;
# ...
my $rows = $db->iquery( '
SELECT title
FROM threads
WHERE date >', \$x, '
AND subject IN', \@subjects, '
' )->arrays;=head1 DESCRIPTION
The recommended way to use L is via its L
integration, which provides an excellent alternative to plain DBI access.Ordinarily, the C method in L integrates L.
But by loading this module instead (or after) L, the C
method will be patched to use L instead.This is all there is to this module.
=cut