NAME

LINQ::Database - LINQ extension for working with databases

SYNOPSIS

use LINQ;
use LINQ::Util -all;
use LINQ::Database;
use DBI;

my $db = 'LINQ::Database'->new( 'DBI'->connect( ... ) );

$db
  ->table( 'pet' )
  ->where( check_fields 'name', -like => 'P%', -nocase )
  ->select( fields 'name', 'species' )
  ->foreach( sub {
    printf( "%s is a %s\n", $_->name, $_->species );
  } );

Or:

use LINQ::DSL ':default_safe';
use LINQ::Database;
use DBI;

my $db = 'LINQ::Database'->new( 'DBI'->connect( ... ) );

my $collection = Linq {
  From $db->table( 'pet' );
  WhereX 'name', -like => 'P%', -nocase;
  SelectX 'name', 'species';
};

printf "Found %d results.\n", $collection->count;

$collection->foreach( sub {
  printf( "%s is a %s\n", $_->name, $_->species );
} );

DESCRIPTION

LINQ::Database provides a LINQ::Collection-compatible interface for accessing SQL databases. It's basically DLinq for Perl.

BUGS

Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=LINQ-Database.

SEE ALSO

LINQ.

AUTHOR

Toby Inkster <tobyink@cpan.org>.

COPYRIGHT AND LICENCE

This software is copyright (c) 2021-2022 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

DISCLAIMER OF WARRANTIES

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.