DBIx-Query
view release on metacpan or search on metacpan
lib/DBIx/Query.pm view on Meta::CPAN
sub sql_uncached {
my ( $self, $sql, $attr, $cache_type, $variables ) = @_;
$cache_type = -1;
return $self->sql( $sql, $attr, $cache_type, $variables );
}
sub get_uncached {
my ( $self, $tables, $columns, $where, $meta, $attr, $cache_type ) = @_;
$cache_type = -1;
return $self->get( $tables, $columns, $where, $meta, $attr, $cache_type );
}
sub sql_fast {
my $self = shift;
carp('sql_fast() is deprecated in favor of sql()');
return $self->sql(@_);
}
sub get_fast {
my $self = shift;
carp('get_fast() is deprecated in favor of get()');
return $self->get(@_);
}
sub add {
my ( $self, $table_name, $params, $attr, $cache_type ) = @_;
my ( $sql, @variables ) = $self->_param('sql_abstract')->insert( $table_name, $params );
$self->_try( sub {
my $sth = $self->sql( $sql, $attr, $cache_type, \@variables );
$sth->execute( @{ $sth->_param('variables') || [] } );
} );
my $pk;
eval {
$pk = $self->last_insert_id(
undef,
undef,
delete $attr->{'last_insert_table'} || $table_name,
undef,
$attr,
);
};
$self->_param( 'table' => $table_name );
return $pk;
}
sub rm {
my ( $self, $table_name, $params, $attr, $cache_type ) = @_;
my ( $sql, @variables ) = $self->_param('sql_abstract')->delete( $table_name, $params );
my $sth = $self->sql( $sql, $attr, $cache_type, \@variables );
$sth->run;
return $self;
}
sub update {
my ( $self, $table_name, $params, $where, $attr, $cache_type ) = @_;
my ( $sql, @variables ) = $self->_param('sql_abstract')->update( $table_name, $params, $where );
my $sth = $self->sql( $sql, $attr, $cache_type, \@variables );
$sth->run;
return $self;
}
sub abstract {
return $_[0]->_param('sql_abstract');
}
sub get_run {
my $self = shift;
my $sth = $self->get(@_);
$self->_try( sub {
$sth->execute( @{ $sth->_param('variables') || [] } );
} );
return $sth;
}
sub fetch_value {
my $self = shift;
my $sth = $self->get_run(@_);
my $value;
$self->_try( sub {
$value = ( $sth->fetchrow_array )[0];
$sth->finish;
} );
return $value;
}
sub fetchall_arrayref {
my $self = shift;
my $sth = $self->get_run(@_);
my $value;
$self->_try( sub {
$value = $sth->fetchall_arrayref;
$sth->finish;
} );
return $value;
}
sub fetchall_hashref {
my $self = shift;
my $sth = $self->get_run(@_);
my $value;
$self->_try( sub {
$value = $sth->fetchall_arrayref({});
$sth->finish;
} );
( run in 0.751 second using v1.01-cache-2.11-cpan-39bf76dae61 )