DBIx-Custom
view release on metacpan or search on metacpan
lib/DBIx/Custom.pm view on Meta::CPAN
if (@$params > 1) {
for my $param (@$params) {
$self->execute($sql, $param, %opt);
}
}
else {
$self->execute($sql, $params->[0], %opt);
}
}
sub update {
my $self = shift;
# Options
my $param = @_ % 2 ? shift : undef;
my %opt = @_;
$param ||= {};
# Don't allow update all rows
confess qq{update method where option must be specified } . _subname
if !$opt{where} && !defined $opt{id} && !$opt{allow_update_all};
lib/DBIx/Custom.pm view on Meta::CPAN
# Update statement
my $sql = "update ";
$sql .= "$opt{prefix} " if defined $opt{prefix};
$sql .= $self->_tq($opt{table}) . " set $assign_clause $w->{clause} ";
# Execute query
$self->execute($sql, $param, %opt);
}
sub update_all { shift->update(@_, allow_update_all => 1) };
sub values_clause {
my ($self, $param, $opts) = @_;
my $wrap = $opts->{wrap} || {};
# Create insert parameter tag
my ($q, $p) = $self->_qp;
my $safety_character = $self->safety_character;
lib/DBIx/Custom.pm view on Meta::CPAN
_deprecate('0.39', "DBIx::Custom::helper method is DEPRECATED!");
# Register method
my $methods = ref $_[0] eq 'HASH' ? $_[0] : {@_};
$self->{_methods} = {%{$self->{_methods} || {}}, %$methods};
return $self;
}
# DEPRECATED
sub update_or_insert {
_deprecate('0.39', "DBIx::Custom::update_or_insert method is DEPRECATED!");
my ($self, $param, %opt) = @_;
confess "update_or_insert method need primary_key and id option "
unless defined $opt{id} && defined $opt{primary_key};
my $statement_opt = $opt{option} || {};
my $rows = $self->select(%opt, %{$statement_opt->{select} || {}})->all;
if (@$rows == 0) {
lib/DBIx/Custom/Model.pm view on Meta::CPAN
# DEPRECATED
sub primary_key {
if (@_ == 1) {
return $_[0]{'primary_key'};
}
$_[0]{'primary_key'} = $_[1];
$_[0];
};
# DEPRECATED
sub update_or_insert {
my ($self, $param, %opt) = @_;
_deprecate('0.39', "DBIx::Custom::Model::update_or_insert method is DEPRECATED!");
confess "update_or_insert method need primary_key and id option "
unless (defined $opt{id} || defined $self->{id})
&& (defined $opt{primary_key} || defined $self->{primary_key});
my $statement_opt = $opt{option} || {};
my $rows = $self->select(%opt, %{$statement_opt->{select} || {}})->all;
( run in 0.288 second using v1.01-cache-2.11-cpan-4d4bc49f3ae )