title: PDO to retrieve and display images without creating files
body: <p>Trying to loop through a test database with images (I know many say not to do this, but it simplifies so much in terms of backups, etc.).  I can get the result I want by creating image files on the fly, but there must be a way to do this without creating files.  Can someone suggest a syntax I can use without having to create these image files?</p>
  
  <p>Here is what I have working:</p>
  
  <pre><code>&lt;?php
  // configuration
  $dbhost     = "localhost";
  $dbname     = "test";
  $dbuser     = "root";
  $dbpass     = "";
  
  // database connection
  $conn = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass);
  
  // query
  $sql = "SELECT id,title,author,description,cover FROM books";
  $q = $conn-&gt;prepare($sql);
  $q-&gt;execute();
  
  $q-&gt;bindColumn(1, $id);
  $q-&gt;bindColumn(2, $title);
  $q-&gt;bindColumn(3, $author);
  $q-&gt;bindcolumn(4, $description);
  $q-&gt;bindColumn(5, $cover, PDO::PARAM_LOB);
  
  while($q-&gt;fetch())
  {
  file_put_contents($id.".png",$cover);
    echo ("&lt;img src='".$id.".png'&gt;&lt;br /&gt;, $title, $author, $description,&lt;br/&gt;");
  }
  ?&gt;
  </code></pre>
  
  <p>I am thinking that we should be able to eliminate the "file_put_contents.." line and in the echo line, replace the </p>
  
  <pre><code>&lt;img src='".$id.".png'&gt;" 
  </code></pre>
  
  <p>with some php/pdo statement that retrieves the blob and puts it in the proper format. Tried a few things, but have not been successful.</p>
  
  <p>Any suggestions would be helpful!</p>