DBIx-ActiveRecord

 view release on metacpan or  search on metacpan

lib/DBIx/ActiveRecord/Arel.pm  view on Meta::CPAN

232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
    $s;
}
 
sub insert {
    my ($self, $hash, $columns) = @_;
    my $o = $self->clone;
    $o->{query} = DBIx::ActiveRecord::Arel::Query::Insert->new($self, $hash, $columns);
    $o;
}
 
sub update {
    my ($self, $hash, $columns) = @_;
    my $o = $self->clone;
    $o->{query} = DBIx::ActiveRecord::Arel::Query::Update->new($self, $hash, $columns);
    $o;
}
 
sub delete {
    my ($self) = @_;
    my $o = $self->clone;
    $o->{query} = DBIx::ActiveRecord::Arel::Query::Delete->new($self);

lib/DBIx/ActiveRecord/Model.pm  view on Meta::CPAN

163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
    $self->_record_timestamp(INSERT_RECORD_TIMESTAMPS);
    my $arel = $s->{arel}->insert($self->to_hash, $self->_global->{columns});
    my $sth = $self->dbh->prepare($arel->to_sql);
    my $res = $sth->execute($arel->binds) || croak $sth->errstr;
 
    my $insert_id = $sth->{'insertid'} || $self->dbh->{'mysql_insertid'};
    $self->{-set}->{$self->_global->{primary_keys}->[0]} = $insert_id if $insert_id;
    $res;
}
 
sub update {
    my ($self) = @_;
    return if !%{$self->{-set}};
    return if !$self->in_storage;
 
    my $s = $self->_pkey_scope;
    $self->_record_timestamp(UPDATE_RECORD_TIMESTAMPS);
    my $arel = $s->{arel}->update($self->{-set}, $self->_global->{columns});
    my $sth = $self->dbh->prepare($arel->to_sql);
    $sth->execute($arel->binds) || croak $sth->errstr;
}

lib/DBIx/ActiveRecord/Scope.pm  view on Meta::CPAN

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
    my $s = $self->scoped;
    $s->{arel} = $s->{arel}->$method(@_);
    $s;
}
 
sub scoped_instance {
    my $self = shift;
    ref $self ? $self : $self->scoped;
}
 
sub update_all {
    my ($self, $sets) = @_;
    $self = $self->scoped;
    my $s = $self->{arel}->update($sets);
    my $sth = $self->{model}->dbh->prepare($s->to_sql);
    $sth->execute($s->binds) || croak $sth->errstr;
}
 
sub delete_all {
    my ($self) = @_;
    $self = $self->scoped;



( run in 0.856 second using v1.01-cache-2.11-cpan-49f99fa48dc )