DBIx::Composer

DBIx::Composer is a Perl module that composes and runs a SQL statement.
Download

DBIx::Composer Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Igor Plisco
  • Publisher web site:
  • http://search.cpan.org/~plisco/DBIx-Composer-1.00/lib/DBIx/Composer.pm

DBIx::Composer Tags


DBIx::Composer Description

DBIx::Composer is a Perl module that composes and runs a SQL statement. DBIx::Composer is a Perl module that composes and runs a SQL statement.SYNOPSIS use DBIx::Composer $cmd = new DBIx::Composer(); $cmd->{table} = 'table1'; $cmd->{fields} = 'name, email'; $cmd->{where} = "where login = 'peter'"; print $cmd->compose_select;# Prints "select name, surname from table1 where login = 'peter'" $dbh = open_database(); # Open database yourself use DBIx::Composer $cmd = new DBIx::Composer(dbh=>$dbh, debug=> 1); $cmd->{table} = 'table1'; $cmd->{fields} = 'login, name, email'; $cmd->{values} = "'john', 'John Smith', 'john@smith.com'"; $cmd->insert();# Executes command "insert into table1 (login, name, email) values # ('john', 'John Smith', 'john@smith.com')"# Prints this command on STDERR before execution.This module helps you to compose and run SQL statements. First you create new object and fill its hash for common parts of SQL statements. Then you may either compose SQL statement from these parts or both compose and execute it.USAGEYou connect to database using your favorite method of connection and supply DBIx::Composer object with standard database handler $dbh. If you don't plan to execute statements, you may omit connection to database.So, after creating new object you set its parameters, or SQL command parts. Modifiers for command, such as "where ...", "order ...", "limit ..." must be full modifiers like "where a=b", not only "a=b".You don't need to prepare() SQL fetch statements - they are prepared internally. You cant execute statements right after setting their parts - the module checks whether command has been composed, prepared and executed. Because of such behaviour don't try to reset command parts after executing, but better create new DBIx::Composer object. Requirements: · Perl


DBIx::Composer Related Software