title: Getting blob type Doctrine entity property returns data only once
body: <p>I use Doctrine to store options/various bits of odd data in an array and serialise it to database where it gets stored as a blob. Everything was working fine until today I had to get that array twice and noticed that it gets the correct value only the first time. Any successive attempts return false, which is what unserialize/stream_get_contents returns on failure.</p>
  
  <p>My best guess is that doctrine closes the stream after it fetches the data, but it doesn't make much sense. I need the data to be available throughout the request. I'm not an expert with streams so:</p>
  
  <p><strong>How can I fetch blob data multiple times or prevent the stream from closing?</strong></p>
  
  <p>Doctrine entity and it's methods:</p>
  
  <pre><code>/**
   * @var resource
   *
   * @ORM\Column(name="options", type="blob")
   */
  private $options;
  
  /**
   * Set options
   *
   * @param array $options
   *
   * @return Campaign
   */
  public function setOptions($options)
  {
      $this-&gt;options = serialize($options);
  
      return $this;
  }
  
  /**
   * Get options
   *
   * @return array
   */
  public function getOptions()
  {
      return unserialize(stream_get_contents($this-&gt;options));
  }
  </code></pre>
  
  <p>Retrieve serialized options array:</p>
  
  <pre><code>$campaign   = $this-&gt;em-&gt;getRepository('TreasureForgeMessageBundle:Campaign')-&gt;find(1);
  $options1   = $campaign-&gt;getOptions(); // Correct options array
  $options2   = $campaign-&gt;getOptions(); // false
  $options3   = $campaign-&gt;getOptions(); // false
  </code></pre>
  
  <p>Many thanks!</p>