DBIx-Class

 view release on metacpan or  search on metacpan

lib/DBIx/Class/Admin.pm  view on Meta::CPAN


=item Arguments: $rs, $set, $where

=back

update takes the name of a resultset from the schema_class, a hashref of data to update and
a where hash used to form the search for the rows to update.

=cut

sub update {
  my ($self, $rs, $set, $where) = @_;

  $rs ||= $self->resultset();
  $where ||= $self->where();
  $set ||= $self->set();
  my $resultset = $self->schema->resultset($rs);
  $resultset = $resultset->search( ($where||{}) );

  my $count = $resultset->count();
  print "This action will modify $count ".ref($resultset)." records.\n" if (!$self->quiet);

lib/DBIx/Class/CDBICompat/LazyLoading.pm  view on Meta::CPAN

sub resultset_instance {
  my $self = shift;
  my $rs = $self->next::method(@_);
  $rs = $rs->search(undef, { columns => [ $self->columns('Essential') ] });
  return $rs;
}


# Emulate that CDBI throws out all changed columns and reloads them on
# request in case the database modifies the new value (say, via a trigger)
sub update {
    my $self = shift;

    my @dirty_columns = keys %{$self->{_dirty_columns}};

    my $ret = $self->next::method(@_);
    $self->_clear_column_data(@dirty_columns);

    return $ret;
}

lib/DBIx/Class/CDBICompat/Triggers.pm  view on Meta::CPAN

  my $self = shift;

  return $self->create(@_) unless ref $self;

  $self->call_trigger('before_create');
  $self->next::method(@_);
  $self->call_trigger('after_create');
  return $self;
}

sub update {
  my $self = shift;
  $self->call_trigger('before_update');
  my @to_update = keys %{$self->{_dirty_columns} || {}};
  return -1 unless @to_update;
  $self->next::method(@_);
  $self->call_trigger('after_update');
  return $self;
}

sub delete {

lib/DBIx/Class/FilterColumn.pm  view on Meta::CPAN

    $self->make_column_dirty($col);
    delete $self->{_column_data}{$col};
  }
  else {
    $self->set_column($col, $self->_column_to_storage($col, $filtered));
  };

  return $self->{_filtered_column}{$col} = $filtered;
}

sub update {
  my ($self, $data, @rest) = @_;

  my $colinfos = $self->result_source->columns_info;

  foreach my $col (keys %{$data||{}}) {
    if ( exists $colinfos->{$col}{_filter_info} ) {
      $self->set_filtered_column($col, delete $data->{$col});

      # FIXME update() reaches directly into the object-hash
      # and we may *not* have a filtered value there - thus

lib/DBIx/Class/Ordered.pm  view on Meta::CPAN

=head2 update

Overrides the DBIC update() method by checking for a change
to the position and/or group columns.  Movement within a
group or to another group is handled by repositioning
the appropriate siblings.  Position defaults to the end
of a new group if it has been changed to undef.

=cut

sub update {
  my $self = shift;

  # this is set by _ordered_internal_update()
  return $self->next::method(@_) if $self->result_source->schema->{_ORDERED_INTERNAL_UPDATE};

  my $upd = shift;
  $self->set_inflated_columns($upd) if $upd;

  my $position_column = $self->position_column;
  my @group_columns = $self->_grouping_columns;

lib/DBIx/Class/Relationship/Base.pm  view on Meta::CPAN


=item Return Value: L<$result|DBIx::Class::Manual::ResultClass>

=back

Update or create a result object of a related class. See
L<DBIx::Class::ResultSet/update_or_create> for details.

=cut

sub update_or_create_related {
  #my ($self, $rel, @args) = @_;
  shift->related_resultset(shift)->update_or_create(@_);
}

=head2 set_from_related

=over 4

=item Arguments: $rel_name, L<$result|DBIx::Class::Manual::ResultClass>

lib/DBIx/Class/Relationship/Base.pm  view on Meta::CPAN


=back

  $book->update_from_related('author', $author_obj);

The same as L</"set_from_related">, but the changes are immediately updated
in storage.

=cut

sub update_from_related {
  my $self = shift;
  $self->set_from_related(@_);
  $self->update;
}

=head2 delete_related

=over 4

=item Arguments: $rel_name, $cond?, L<\%attrs?|DBIx::Class::ResultSet/ATTRIBUTES>

lib/DBIx/Class/Relationship/CascadeActions.pm  view on Meta::CPAN

      }
    }

    $guard->commit;
    return $ret;
  }

  $self->next::method(@rest);
}

sub update {
  my ($self, @rest) = @_;
  return $self->next::method(@rest) unless ref $self;
    # Because update cascades on a class *really* don't make sense!

  my $source = $self->result_source;
  my %rels = map { $_ => $source->relationship_info($_) } $source->relationships;
  my @cascade = grep { $rels{$_}{attrs}{cascade_update} } keys %rels;

  if (@cascade) {
    my $guard = $source->schema->txn_scope_guard;

lib/DBIx/Class/ResultSet.pm  view on Meta::CPAN


Note that L</update> does not process/deflate any of the values passed in.
This is unlike the corresponding L<DBIx::Class::Row/update>. The user must
ensure manually that any value passed to this method will stringify to
something the RDBMS knows how to deal with. A notable example is the
handling of L<DateTime> objects, for more info see:
L<DBIx::Class::Manual::Cookbook/Formatting DateTime objects in queries>.

=cut

sub update {
  my ($self, $values) = @_;
  $self->throw_exception('Values for update must be a hash')
    unless ref $values eq 'HASH';

  return $self->_rs_update_delete ('update', $values);
}

=head2 update_all

=over 4

lib/DBIx/Class/ResultSet.pm  view on Meta::CPAN

=item Return Value: 1

=back

Fetches all objects and updates them one at a time via
L<DBIx::Class::Row/update>. Note that C<update_all> will run DBIC defined
triggers, while L</update> will not.

=cut

sub update_all {
  my ($self, $values) = @_;
  $self->throw_exception('Values for update_all must be a hash')
    unless ref $values eq 'HASH';

  my $guard = $self->result_source->schema->txn_scope_guard;
  $_->update({%$values}) for $self->all;  # shallow copy - update will mangle it
  $guard->commit;
  return 1;
}

lib/DBIx/Class/ResultSet.pm  view on Meta::CPAN

See also L</find> and L</find_or_create>. For information on how to declare
unique constraints, see L<DBIx::Class::ResultSource/add_unique_constraint>.

If you need to know if an existing row was updated or a new one created use
L</update_or_new> and L<DBIx::Class::Row/in_storage> instead. Don't forget
to call L<DBIx::Class::Row/insert> to save the newly created row to the
database!

=cut

sub update_or_create {
  my $self = shift;
  my $attrs = (@_ > 1 && ref $_[$#_] eq 'HASH' ? pop(@_) : {});
  my $cond = ref $_[0] eq 'HASH' ? shift : {@_};

  my $row = $self->find($cond, $attrs);
  if (defined $row) {
    $row->update($cond);
    return $row;
  }

lib/DBIx/Class/ResultSet.pm  view on Meta::CPAN

B<Note>: Take care when using C<update_or_new> with a table having
columns with default values that you intend to be automatically
supplied by the database (e.g. an auto_increment primary key column).
In normal usage, the value of such columns should NOT be included at
all in the call to C<update_or_new>, even when set to C<undef>.

See also L</find>, L</find_or_create> and L</find_or_new>.

=cut

sub update_or_new {
    my $self  = shift;
    my $attrs = ( @_ > 1 && ref $_[$#_] eq 'HASH' ? pop(@_) : {} );
    my $cond  = ref $_[0] eq 'HASH' ? shift : {@_};

    my $row = $self->find( $cond, $attrs );
    if ( defined $row ) {
        $row->update($cond);
        return $row;
    }

lib/DBIx/Class/ResultSetProxy.pm  view on Meta::CPAN


sub search           { shift->resultset_instance->search(@_);           }
sub search_literal   { shift->resultset_instance->search_literal(@_);   }
sub search_like      { shift->resultset_instance->search_like(@_);      }
sub count            { shift->resultset_instance->count(@_);            }
sub count_literal    { shift->resultset_instance->count_literal(@_);    }
sub find             { shift->resultset_instance->find(@_);             }
sub create           { shift->resultset_instance->create(@_);           }
sub find_or_create   { shift->resultset_instance->find_or_create(@_);   }
sub find_or_new      { shift->resultset_instance->find_or_new(@_);      }
sub update_or_create { shift->resultset_instance->update_or_create(@_); }

1;

lib/DBIx/Class/Row.pm  view on Meta::CPAN

To determine before calling this method, which column values have
changed and will be updated, call L</get_dirty_columns>.

To check if any columns will be updated, call L</is_changed>.

To force a column to be updated, call L</make_column_dirty> before
this method.

=cut

sub update {
  my ($self, $upd) = @_;

  $self->set_inflated_columns($upd) if $upd;

  my %to_update = $self->get_dirty_columns
    or return $self;

  $self->throw_exception( "Not in database" ) unless $self->in_storage;

  my $rows = $self->result_source->storage->update(

lib/DBIx/Class/Row.pm  view on Meta::CPAN

=head2 insert_or_update

  $obj->insert_or_update

Alias for L</update_or_insert>

=cut

sub insert_or_update { shift->update_or_insert(@_) }

sub update_or_insert {
  my $self = shift;
  return ($self->in_storage ? $self->update : $self->insert);
}

=head2 is_changed

  my @changed_col_names = $result->is_changed();
  if ($result->is_changed()) { ... }

=over

lib/DBIx/Class/SQLMaker/MySQL.pm  view on Meta::CPAN

        $parenthesized = join ' ', '(', $self->$force_double_subq( $parenthesized ), ')';
      }
    }

    $new_sql .= $prefix . $parenthesized;
  }

  return $new_sql . $sql;
};

sub update {
  my $self = shift;

  # short-circuit unless understood identifier
  return $self->next::method(@_) unless $self->{_modification_target_referenced_re};

  my ($sql, @bind) = $self->next::method(@_);

  $sql = $self->$force_double_subq($sql)
    if $sql =~ $self->{_modification_target_referenced_re};

lib/DBIx/Class/Storage.pm  view on Meta::CPAN

=cut

sub insert { die "Virtual method!" }

=head2 update

Handle an update statement.

=cut

sub update { die "Virtual method!" }

=head2 delete

Handle a delete statement.

=cut

sub delete { die "Virtual method!" }

=head2 select_single

lib/DBIx/Class/Storage/DBI.pm  view on Meta::CPAN

  }
  catch {
    $err = shift unless defined $err;
  };

  $self->throw_exception($err) if defined $err;

  return $count;
}

sub update {
  #my ($self, $source, @args) = @_;
  shift->_execute('update', @_);
}


sub delete {
  #my ($self, $source, @args) = @_;
  shift->_execute('delete', @_);
}

lib/DBIx/Class/Storage/DBI/ODBC/ACCESS.pm  view on Meta::CPAN

      last;
    }
  }

  local $self->{disable_sth_caching} = 1 if $is_image_insert
    && $self->disable_sth_caching_for_image_insert_or_update;

  return $self->next::method(@_);
}

sub update {
  my $self = shift;
  my ($source, $fields) = @_;

  my $columns_info = $source->columns_info;

  my $is_image_insert = 0;

  for my $col (keys %$fields) {
    if ($self->_is_binary_lob_type($columns_info->{$col}{data_type})) {
      $is_image_insert = 1;

lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm  view on Meta::CPAN

      ($identity_col => $self->last_insert_id($source, $identity_col)) : ()),
    %$to_insert,
    %$updated_cols,
  };

  $self->_insert_blobs ($source, $blob_cols, $final_row) if $blob_cols;

  return $updated_cols;
}

sub update {
  my $self = shift;
  my ($source, $fields, $where, @rest) = @_;

  #
  # When *updating* identities, ASE requires SET IDENTITY_UPDATE called
  #
  if (my $blob_cols = $self->_remove_blob_cols($source, $fields)) {

    # If there are any blobs in $where, Sybase will return a descriptive error
    # message.



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