1 package DBIx::Class::SQL;
6 use base qw/Class::Data::Inheritable/;
8 use constant COLS => 0;
9 use constant FROM => 1;
10 use constant COND => 2;
14 DBIx::Class::SQL - SQL Specific methods for DBIx::Class
20 This class contains methods that generates SQL queries for
21 the rest of the L<DBIx::Class> hiarchy. It's also responsible
26 __PACKAGE__->mk_classdata('_sql_statements',
29 sub { "SELECT ".join(', ', @{$_[COLS]})." FROM $_[FROM] WHERE $_[COND]"; },
31 sub { "UPDATE $_[FROM] SET ".join(', ', map { "$_ = ?" } @{$_[COLS]}).
34 sub { "INSERT INTO $_[FROM] (".join(', ', @{$_[COLS]}).") VALUES (".
35 join(', ', map { '?' } @{$_[COLS]}).")"; },
37 sub { "DELETE FROM $_[FROM] WHERE $_[COND]"; },
41 my ($class, $name, $cols, $from, $cond) = @_;
42 my $sql = $class->_sql_statements->{$name}->($cols, $from, $cond);
48 my ($class, $sql) = @_;
49 return $class->_get_dbh->prepare($sql);
54 return $class->_sql_to_sth($class->_get_sql(@_));
61 Matt S. Trout <perl-stuff@trout.me.uk>
65 You may distribute this code under the same terms as Perl itself.