DbFramework
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/DbFramework/Persistent.pm view on Meta::CPAN
Update this object in the associated table. I<%attributes> is a hash
whose keys contain primary key column names and whose values will be
concatenated with 'ANDs' to form a SQL 'WHERE' clause. The default
values of I<%attributes> is the hash returned by attributes_h(). Pass
the B<current> primary key attributes as an argument in I<%attributes>
when you need to update one or more primary key columns. Returns the
number of rows updated if supplied by the DBI driver.
=cut
sub update {
my $self = attr shift;
my %attributes = defined($_[0]) ? %{$_[0]} : %{$self->attributes_h};
# get pk attributes
my %pk_attributes;
for ( $TABLE->is_identified_by->attribute_names ) {
$pk_attributes{$_} = $attributes{$_};
}
return $TABLE->update($self->attributes_h,$self->where_and(\%pk_attributes));
}
lib/DbFramework/Table.pm view on Meta::CPAN
#------------------------------------------------------------------------------
=head2 update(\%values,$conditions)
UPDATE the table SETting the columns matching the keys in %values to
the values in %values WHERE I<$conditions> are met. Returns the
number of rows updated if supplied by the DBI driver.
=cut
sub update {
my $self = attr shift;
my %values = %{$_[0]};
my $conditions = $_[1];
my $values;
for ( keys %values ) {
next unless $values{$_};
my $dt = $self->get_attributes($_)->references;
my $type = $dt->ansii_type;
print STDERR "\$type = ",$dt->name,"($type)\n" if $_DEBUG;
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.510 second using v1.00-cache-2.02-grep-82fe00e-cpan-4673cadbf75 )