Slide 34
Slide 34 text
Tengの場合の差分
34
package Sample::Service::User;
# Update
sub update_user {
my ($class, $db, $user, $params) = @_;
# 変更がなかったら更新しない
return if (
$user->name eq $params->{name} &&
$user->type eq $params->{type}
);
- $db->query(q[
- UPDATE user
- SET name = :name
- SET type = :type
- WHERE id = :id
- ], {
- name => $params->{name},
- type => $params->{type},
- id => $user->id,
- });
+ $teng->update('user', $params, { id =>
$user->id });
}