The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Bio::DB::Query::SqlGenerator - Object representing an SQL Query

SYNOPSIS

    use Bio::DB::Query::BioQuery;
    use Bio::DB::Query::SqlGenerator;

    # get a Bio::DB::Query::AbstractQuery or derived query somehow
    my $query = Bio::DB::Query::BioQuery->new(-tables => ["table1, table2"]);
    $query->where(["and",
                   ["or", "col4 = ?", "col5 = 'somevalue'"],
                   ["col2 = col4", "col6 not like 'abcd*'"]]);

    # use the generator to turn a query object into SQL
    my $sqlgen = Bio::DB::Query::SqlGenerator->new(-query => $query);
    my $sql = $sqlgen->generate_sql();
    print "SQL: $SQL\n";

    # then bind as necessary, and execute ...

DESCRIPTION

This represents the strategy pattern for generating a SQL statement given a Query object.

Eventually there should be interfaces for this pattern as well as for the Query.

AUTHOR Chris Mungall, Hilmar Lapp

Chris Mungall, cmungall@fruitfly.org Hilmar Lapp, hlapp at gmx.net

This is essentially code ripped out of SqlQuery.pm and AbstractQuery.pm (both by Chris Mungall), put into its own module as a strategy pattern.

APPENDIX

The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _

new

query

 Title   : query
 Usage   : $obj->query($newval)
 Function: Get/set query object (a Bio::DB::Query::AbstractQuery or derived
           instance).
 Example : 
 Returns : value of query (a Bio::DB::Query::AbstractQuery or derived)
 Args    : new value (a Bio::DB::Query::AbstractQuery or derived, optional)

generate_sql

  Usage:  $sqlstmt = $sqlgen->generate_sql; $dbh->do($sqlstmt);
          $sqlstmt = $sqlgen->generate_sql($query); $dbh->do($sqlstmt);

Flattens query object into a SQL statement.