DBIx-SQLEngine

 view release on metacpan or  search on metacpan

SQLEngine/Record/Cache.pm  view on Meta::CPAN

Attempts to update the record using its primary key as a unique identifier. 
Calls SUPER method, so implemented using MIXIN.

Clears the cache.

=back

=cut

# $record->update_record()
sub update_record {
  my $self = shift;
  $self->cache_clear();
  $self->NEXT('update_record', @_ );
}

########################################################################

=head2 Delete to Remove Records

=over 4

SQLEngine/Record/Cache.pm  view on Meta::CPAN

  
  my $id_col = $row->table_or_die()->id_column();
  my $row_cache = $row->row_cache;
  if ( $id_col and $row_cache ) {
    $row_cache->replace( $row->{$id_col}, $row );
  }
  
  return $row->NEXT('insert_row', @_);
}

sub update_row {
  my $row = shift;
  $row->query_cache->clear_all() if ( $row->query_cache );
  return $row->NEXT('update_row', @_);
}

sub delete_row {
  my $row = shift;
  
  my $id_col = $row->table_or_die()->id_column();
  my $row_cache = $row->row_cache;

SQLEngine/Record/Extras.pm  view on Meta::CPAN

}

########################################################################

sub change { (shift)->change_values() }

########################################################################

sub save_row   { (shift)->save_record(@_) }
sub insert_row { (shift)->insert_record( @_ ) }
sub update_row { (shift)->update_record( @_ ) }
sub delete_row { (shift)->delete_record( @_ ) }

########################################################################

1;

SQLEngine/Record/Hooks.pm  view on Meta::CPAN


Inheritable Hook. Add functions which should be called immediately after a row is updated.

=back

=cut

use Class::MakeMethods::Composite::Inheritable(hook=>'ok_update pre_update post_update'); 

# $record->update_record()
sub update_record {
  my $self = shift;
  my $class = ref( $self ) or croak("Not a class method");
  my @flags = $self->ok_update;
  if ( grep { length $_ and ! $_ } @flags ) {
    # warn "Cancelling update of $self: " . join(', ', map "'$_'", @flags );
    return undef;
  } 
  # warn "About to update $self: " . join(', ', map "'$_'", @flags );
  $self->pre_update();
  $self->NEXT('update_record');

SQLEngine/Record/Table.pm  view on Meta::CPAN


  $record_obj->update_record() : $record_count

Attempts to update the record using its primary key as a unique identifier. Returns the number of rows affected, which should be 1 unless there's an error.

=back

=cut

# $record_obj->update_record();
sub update_record {
  (shift)->table_record_method('update_row');
}

########################################################################

=head2 Delete to Remove Records

=over 4

=item delete_record()

SQLEngine/Schema/Table.pm  view on Meta::CPAN

=back

=cut

# $self->do_update( %clauses);
sub do_update {
  (shift)->sqlengine_do('do_update', @_ )
}

# $self->update_row( $row );
sub update_row {
  my($self, $row) = @_;
  
  $self->sqlengine_do('do_update', 
    columns => [ $self->column_names ],
    where => $self->primary_criteria( $row ),
    values => $row,
  );
}

# $self->update_rows( @hashes );
sub update_rows {
  my $self = shift;
  my $rc;
  foreach my $row ( @_ ) { $rc += $self->update_row( $row ) }
  $rc
}

########################################################################

=head2 Delete to Remove Rows



( run in 0.264 second using v1.01-cache-2.11-cpan-4d4bc49f3ae )