Hi,

I'm writing a module that, using the magic of source filters, allows you 
to write SQL in a database-independent perl-ish notation. I've seen 
things like DBIx::Abstract which allow you to write SQL in perl, but 
because of their strong use of refs code using such modules tends to 
be long, unfriendly and rather too deeply nested. Code to use this 
module is supposed to feel more like a perl expression than a data 
structure.

I'm toying with names like:

DBIx::Filter
Filter::SQL

but these don't quite seem to work - they rather overstress the fact it 
uses source code filters which shouldn't be so important.

Example use code (work in progress):

$dbh = DBI->connect("DBI:mysql:database=cache", "", "");

foreach(qw(oranges apples pears)) {

        my $sth = $dbh->DBIx::Filter::select(
                [food=>price(food->id==price->food_id)],
                (food->description eq $_) && price->active == 1
        );
}

(which becomes "select * from food right join price on 
(food.id=price.food_id) where food.description = ? and price.active = 1" 
where $_ is used as the bind param).

Thanks,

Luke

Reply via email to