From 09933e11a6f2fb40526d2f41bec156d22b2974b4 Mon Sep 17 00:00:00 2001
From: Magali Ruffier <mr6@ebi.ac.uk>
Date: Fri, 5 Oct 2012 15:42:47 +0000
Subject: [PATCH] if the query returns more than one column, execute will store
 the result in an array of arrays if there is only one row, result can be
 retrieved by fetching the first element of the de-referenced array, which is
 itself an array where each element corresponds to a column

---
 .../Pipeline/Production/StatsGenerator.pm        | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/modules/Bio/EnsEMBL/Pipeline/Production/StatsGenerator.pm b/modules/Bio/EnsEMBL/Pipeline/Production/StatsGenerator.pm
index 2ac23d53cb..10ffd7fda6 100644
--- a/modules/Bio/EnsEMBL/Pipeline/Production/StatsGenerator.pm
+++ b/modules/Bio/EnsEMBL/Pipeline/Production/StatsGenerator.pm
@@ -66,23 +66,11 @@ sub store_attrib {
   my $aa          = Bio::EnsEMBL::Registry->get_adaptor($self->param('species'), 'core', 'Attribute');
   my $prod_dba    = $self->get_production_DBAdaptor();
   my $prod_helper = $prod_dba->dbc()->sql_helper();
-  my ($name, $description);
   my $sql = q{
-    SELECT name
+    SELECT name, description
     FROM attrib_type
     WHERE code = ? };
-  my @names = @{ $prod_helper->execute_simple(-SQL => $sql, -PARAMS => [$code]) };
-  foreach my $bit (@names) {
-    $name .= $bit . " ";
-  }
-  $sql = q{
-    SELECT description
-    FROM attrib_type
-    WHERE code = ? };
-  my @descriptions = @{ $prod_helper->execute_simple(-SQL => $sql, -PARAMS => [$code]) };
-  foreach my $bit (@descriptions) {
-    $description .= $bit . " ";
-  }
+  my ($name, $description) = @{$prod_helper->execute(-SQL => $sql, -PARAMS => [$code])->[0]};
   my $attrib = Bio::EnsEMBL::Attribute->new(
     -NAME        => $name,
     -CODE        => $code,
-- 
GitLab