package Fey; use strict; use warnings; our $VERSION = '0.17'; 1; __END__ =head1 NAME Fey - Better SQL Generation Through Perl =head1 SYNOPSIS use Fey::Literal::Function; use Fey::Placeholder; use Fey::Schema; use Fey::SQL; my $schema = hand_waving(); my $user = $schema->table('User'); my $group = $schema->table('Group') my $select = Fey::SQL->new_select(); my $func = Fey::Literal::Function->new( 'LCASE', $user->column('username') ); $select->select( $user->columns( 'user_id', 'username' ) ) ->from( $user, $group ) ->where( $group->group_id, 'IN', 1, 2, 3 ) ->and ( $func, 'LIKE', 'smith%' ); print $select->sql($dbh); =head1 DESCRIPTION The C distribution contains a set of modules for representing the components of a DBMS schema, and for dynamically generating SQL queries based on that schema. =head1 EARLY VERSION WARNING B =head1 USAGE Loading this module does nothing. It's just here to provide docs and a version number for the distro. You'll want to take a look at L, L, and other modules in the distro for more details. =head1 WHAT IS Fey? The goal of the core C distro is to provide a simple, flexible way of I generating complex SQL queries in Perl. Other packages build on top of this functionality to create a complete ORM (C). =head1 GETTING STARTED If you're interested in an ORM, take a look at the C distro. To generate SQL with Fey, you first need to create a set of objects representing the tables and foreign keys in your schema. The simplest way to do this is to use the C distro, which will connect to an existing schema and generate a set of objects for you. Alternatively, you can create these objects via Fey's API. You would first create a L object. This object will hold all of your tables and foreign keys. If you want to create your schema this way, you should start with the L, L, and L APIs. You'll also want to use the L API. Once you have a schema, you can generate SQL using L, or a DBMS-specific subclass of L. =head1 THE CORE Fey DISTRO The emphasis in the core Fey distro is on dynamic queries, particularly on the tables/columns/etc involved in the query, not just the bound parameters. This is I what I mean by a dynamic query ... SELECT user_id FROM User where username = ? While this is dynamic in the sense that the username is parameter-ized and may change on each invocation, it is still easily handled by a phrasebook class. If that is all you need, I suggest checking out any of C, C, or C on CPAN. Imagine that we have a database with a User table and a Message table, where each message has a user who is that message's creator. We might want to grab all the users in the database, in which case we would do a simple C