SQL::String

SQL::String is an object representation of a chunk of SQL.
Download

SQL::String Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Adam Kennedy
  • Publisher web site:
  • http://search.cpan.org/~adamk/

SQL::String Tags


SQL::String Description

SQL::String is an object representation of a chunk of SQL. SQL::String is an object representation of a chunk of SQL.SYNOPSIS < iAlias > I hate SQL:: < iAlias > Guess what SQL::Snippit is < brevity > a not very useful library. I've looked at that. < iAlias > "A snippit of SQL"? NO! A giant complex library and storage and frameworks and junk < iAlias > That's all I want < iAlias > Every decent name I could take for a simple little tied-param chunk of SQL is taken by a "giant framework" < brevity > Alias: the reason is because SQL does not lend itself to small helpful modules < iAlias > It's like CGI all over again :) < rhizo > hehe < brevity > alias: dunno if you want to make your own big framework < iAlias > I have my own big framework :) < xantus_ > heh < iAlias > I just want some nice little toys to clean it up a bit < iAlias > aha! Nobody has taken SQL::String yet < iAlias > It's mine I tellses you! My own... my precious...SQL::String is a simple object class that lets you create "chunks" of SQL that intrinsicly have their parameters attached to them.Quite a few standard SQL queries won't need this, you create your main select statement once, and then provide the parameters different for each call.However, several types of queries can benefit from this. In particular, the creation of large and complex search queries can be tricky to build what might be 1000 character of SQL and keep track of all the required parameters (short of doing them in a named form, with all the problems of namespace management that entails).SQL::String solves this problem by embedding the parameters into the SQL.A SQL::String object exists as a reference to an array containing the SQL, and a number of parameters intended to be used with it.More usefully, SQL::String overloads concatonation so that you can still use a SQL::String object naturally is if it was just SQL.Once you have created your large complex query, you simple split out the SQL and parameters parts and hand them off to DBI normally.Although SQL::String WILL check to make sure that the SQL is a simple string of at least one character, it makes no judgements whatsoever about the parameters. undef, references, objects, everything is legal.This enables custom database backends that do translation of non-DBI parameters normally.OverloadsSQL::String objects ALWAYS evaluate as true, stringify to just the SQL, and act properly in concatination, merging in other parameters in the correct order as expected.The concatination is completely interpolation-safe. That is you can do something like the following. my $sql = SQL::String( 'foo = ?', 10 ); $sql = "select * from table where $sql";Sub-classingDue to the nature of it's internal design, for the time being you are forbidden to sub-class SQL::String.There are some future issues relating to internal structure and XS acceleration that have not been resolved. Requirements: · Perl


SQL::String Related Software