Commit 546c8ea2 authored by Daniel Rios's avatar Daniel Rios
Browse files

bind parameters in update & store methods

parent 91995ddb
......@@ -445,9 +445,9 @@ sub store {
$sth->bind_param(2,$analysis->display_label(),SQL_VARCHAR);
$sth->bind_param(3,$analysis->description,SQL_LONGVARCHAR);
$sth->bind_param(4,$analysis->displayable,SQL_TINYINT);
# $sth->bind_param(5,$analysis->web_data(),SQL_LONGVARCHAR);
my $web_data = $self->dump_data($analysis->web_data());
#$sth->bind_param(5,$analysis->web_data(),SQL_LONGVARCHAR);
my $web_data;
$web_data = $self->dump_data($analysis->web_data()) if ($analysis->web_data());
$sth->bind_param(5,$web_data,SQL_LONGVARCHAR);
$sth->execute();
......@@ -524,24 +524,33 @@ sub update {
# not already there
$sth = $self->prepare("SELECT description FROM analysis_description WHERE analysis_id= ?");
$sth->execute($a->dbID);
my $web_data; #this is an anonymous reference to a hash, will have to be dumped into string before writing to db
if ($sth->fetchrow_hashref) { # update if exists
my $web_data;
$web_data = $self->dump_data($a->web_data()) if ($a->web_data());
$sth = $self->prepare
$sth = $self->prepare
("UPDATE analysis_description SET description = ?, display_label = ?, displayable = ?, web_data = ? WHERE analysis_id = ?");
$sth->execute($a->description(), $a->display_label(), $a->displayable(), $web_data, $a->dbID);
$sth->bind_param(1,$a->description,SQL_LONGVARCHAR);
$sth->bind_param(2,$a->display_label(),SQL_VARCHAR);
$sth->bind_param(3,$a->displayable,SQL_TINYINT);
# print "after $web_data\n";
$sth->bind_param(4,$web_data,SQL_LONGVARCHAR);
$sth->bind_param(5,$a->dbID,SQL_INTEGER);
$sth->execute();
} else { # create new entry
if( $a->description() || $a->display_label() || $a->web_data) {
my $web_data;
$web_data = $self->dump_data($a->web_data()) if ($a->web_data());
$web_data = $self->dump_data($a->web_data()) if ($a->web_data());
#my $web_data = $self->dump_data($a->web_data());
$sth = $self->prepare( "INSERT IGNORE INTO analysis_description (analysis_id, display_label, description, displayable, web_data) VALUES (?,?,?,?,?)");
$sth->execute( $a->dbID(), $a->display_label(), $a->description(), $a->displayable(), $web_data );
$sth->finish();
$sth->bind_param(1,$a->dbID,SQL_INTEGER);
$sth->bind_param(2,$a->display_label(),SQL_VARCHAR);
$sth->bind_param(3,$a->description,SQL_LONGVARCHAR);
$sth->bind_param(4,$a->displayable,SQL_TINYINT);
#my $web_data = $self->dump_data($a->web_data());
$sth->bind_param(5,$web_data,SQL_LONGVARCHAR);
$sth->execute();
}
}
......
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