DBIx-ActiveRecord
view release on metacpan or search on metacpan
lib/DBIx/ActiveRecord/Arel.pm view on Meta::CPAN
232233234235236237238239240241242243244245246247248249250251252
$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
163164165166167168169170171172173174175176177178179180181182183
$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
353637383940414243444546474849505152535455
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 )