in reply to DBIx::Pretty (was DBI::Pretty)
I've seen this approach to "removing" SQL from code before. You're not actually achieving much.
Here's the real Perl code to do what you do in your POD, using Tangram:
# return an object representing the "remote" object, ie the # one in the object store my $remote_customer = $db->remote("Customer"); # get all customers whose name is like ?Wall my (@objs) = $db->select( $remote_customer, $remote_customer->{name}->like("?Wall") ); # set the first one's balance to 10000 $obj[0]->{balance} = 10000; $db->store($obj[0]);
Other things:
I would change:
croak "DBI::Pretty requires a valid DBI object" unless $dbi;
to:
croak "DBI::Pretty requires a valid DBI object" unless (ref $dbi and $dbi->isa("DBI"));
Wouldn't it also be cleaner to write:
sub new($$;$) { my ($class, $dbi, $hash) = (@_); croak "DBI::Pretty requires a valid DBI object" unless $dbi; $hash ||= {};
instead of:
sub new { my $class = shift; my $dbi = shift; croak "DBI::Pretty requires a valid DBI object" unless $dbi; my $hash = shift || {};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: DBI::Pretty
by Masem (Monsignor) on Jul 01, 2001 at 15:47 UTC | |
by miyagawa (Chaplain) on Jul 01, 2001 at 16:23 UTC |