Commit 4e75e59c authored by Keith Jolley's avatar Keith Jolley
Browse files

Remove use of deprecated Datastore::run_simple_query.

parent 7bb93b52
#Written by Keith Jolley
#Copyright (c) 2010-2014, University of Oxford
#Copyright (c) 2010-2015, University of Oxford
#E-mail: keith.jolley@zoo.ox.ac.uk
#
#This file is part of Bacterial Isolate Genome Sequence Database (BIGSdb).
......@@ -142,10 +142,7 @@ sub print_page {
( $continue, $auth_cookies_ref ) = $self->authenticate( \%page_attributes );
}
return if !$continue;
my $user_status;
my $user_status_ref =
$self->{'datastore'}->run_simple_query( "SELECT status FROM users WHERE user_name=?", $page_attributes{'username'} );
$user_status = $user_status_ref->[0] if ref $user_status_ref eq 'ARRAY';
my $user_status = $self->{'datastore'}->run_query( "SELECT status FROM users WHERE user_name=?", $page_attributes{'username'} );
if ( !defined $user_status || ( $user_status eq 'user' ) ) {
$page_attributes{'error'} = 'invalidCurator';
$page = BIGSdb::ErrorPage->new(%page_attributes);
......
......@@ -345,10 +345,9 @@ sub _check_sequences {
push @$problems, "Allele id must not contain spaces - try substituting with underscores (_).<br />";
} else {
$newdata->{'sequence'} =~ s/\s//g;
my $exist_ref =
my $exists =
$self->{'datastore'}
->run_simple_query( "SELECT allele_id FROM sequences WHERE locus=? AND sequence=?", $newdata->{'locus'}, $newdata->{'sequence'} );
my $exists = ref $exist_ref eq 'ARRAY' ? $exist_ref->[0] : undef;
->run_query( "SELECT allele_id FROM sequences WHERE locus=? AND sequence=?", [ $newdata->{'locus'}, $newdata->{'sequence'} ] );
if ($exists) {
my $cleaned_locus = $self->clean_locus( $newdata->{'locus'} );
push @$problems, "Sequence already exists in the database ($cleaned_locus: $exists).<br />";
......
......@@ -1641,7 +1641,7 @@ sub run_query {
eval { $sql->execute(@$values) };
$logger->logcarp($@) if $@;
if ( $options->{'fetch'} eq 'row_arrayref' ) { return $sql->fetchrow_arrayref } #returns undef when no rows
elsif ( $options->{'fetch'} eq 'row_array' ) { return $sql->fetchrow_array } #returns () when no rows
elsif ( $options->{'fetch'} eq 'row_array' ) { return $sql->fetchrow_array } #returns () when no rows, (undef-scalar context)
elsif ( $options->{'fetch'} eq 'row_hashref' ) { return $sql->fetchrow_hashref } #returns undef when no rows
elsif ( $options->{'fetch'} eq 'all_hashref' ) {
if ( !defined $options->{'key'} ) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment