in reply to Simple Template System That Supports Conditional Content?

I'd like to solve my sql syntax tasks with SQL::Abstract and process the execution with DBI.
use strict; use warnings; use DBI; use SQL::Abstract; my $dbh = DBI->connect( 'dbi:mysql:test', 'user', 'pass', {RaiseError => 1, AutoCommit => 1, ShowErrorStatement => 1}); my $sql = SQL::Abstract->new; my $table_name = 'CUSTOMER'; my $customer_number = some_param_method('customer_id'); # defined some +where my @customer_data = get_customer_data(); # defined somewhere my @columns = qw(CUSTOMER_NAME AGE STATUS ADDRESS PHONE); my %values; for (0 .. $#columns) { $values{$columns[$_]} = $customer_data[$_] if defined $customer_data[$_]; } my($query, @binds) = $sql->update( $table_name, \%values, # handles SET COLUMN = ? { CUSTOMER_NUMBER => $customer_number }, # handles WHERE clause ); my $sth = $dbh->prepare($query); $sth->execute(@binds);

Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!