title: Is there a 'one-shot' way to pull data from MySql using Perl?
body: <p>I have a MySql database that contains all the text for a multilingual website, with each different language in a separate column. (For example, the column 'en', id 1 = 'Hello', column 'fr', id 1 = 'Bonjour', and so on)</p>
  
  <p>I am using a Perl/DBI script that pulls the text from the database according to the user language and required section in the usual way by preparing a query, executing the query, then copying the resulting records to an array. This all seems terribly cumbersome and inefficient to me though.</p>
  
  <p>Here's the business end of what I'm using now.</p>
  
  <pre><code>omy (@TEXT, $getText);
  $getText = $dbh-&gt;prepare("SELECT `$language` FROM text WHERE Page_Section = ? ORDER BY line_number");
  $getText-&gt;execute('Section_Name');
  while($_ =  $getText-&gt;fetchrow_array){push(@TEXT, $_)};
  $getText-&gt;finish;
  
  print qq~
  &lt;p&gt;$TEXT[0]&lt;/p&gt;
  &lt;p&gt;$TEXT[1]&lt;/p&gt;
  &lt;p&gt;$TEXT[2]&lt;/p&gt;
  ~;
  </code></pre>
  
  <p>The problem with this method for me is, what if I want to delete one of those lines from the database, or add in a few new lines? It messes up the whole script which is only incrementing 'blindly' through the array from the beginning. In this example, if I deleted the second row in the database and wanted to insert two new lines, I would have to rewrite the relevant parts of the script, otherwise it will print in the wrong order.</p>
  
  <p>I could of course pull each line of text by 'absolute' ID, but that requires a separate 'execute' statement and 'fetchrow_array' line for every bit of text that I want.</p>
  
  <p>Is there a neater way, like a one-shot 'pull and print' method where I just can grab single fields and output them according to ID? Something like.. (warning - pseudo-code cometh)</p>
  
  <pre><code>$query = $dbh-&gt;prepare(SELECT 'language' FROM 'text' WHERE 'id' = ?);
  
  print qq~
  &lt;p&gt;$query-&gt;execute(0)&lt;/p&gt;
  &lt;p&gt;$query-&gt;execute(1)&lt;/p&gt;
  &lt;p&gt;$query-&gt;execute(2)&lt;/p&gt;
  ~;
  $query-&gt;finish;
  </code></pre>
  
  <p>You get the idea.. ;)
  Is something like this possible? Thanks in advance!</p>