I'm trying to save a file in an *Oracle* *BLOB* with symfony2 and Doctrine.

I'm using Symfony 2.7.25, PHP 5.5 and Oracle 11.

I found many others doing the same and adopting their solutions I got a PDO 
error 

Warning: PDOStatement::execute(): supplied argument is not a valid stream 
resource

I have an entity with the blob field declared as follow:

class AttachmentData{
    /**
     * @var string
     *
     * @ORM\Column(name="DATA", type="blob", nullable=true)
     */
    private $data;

In my controller I save the file in this way:

$stream= fopen($attachment->getRealPath(),'rb');
$fileData->setData(stream_get_contents($stream));
$file->setData($fileData);
$em->persist($fileData);
$em->flush();

This error makes sense, because in the doctrine documentation at chapter 
8.2 
http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html#mapping-matrix
 is 
written that the *blob* type is converted i a PHP *resources* but 
*stream_get_contents* returns a string.

I finally tryed to pass just the file resources like:

$stream= fopen($attachment->getRealPath(),'rb');

$file->setData($stream);

In this case I got no error and the records where saved in the DB, however, 
the BLOB field is empty.

Do someone have any idea?

Thanks

Marco

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to