Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/256.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用命令将文件另存为BLOB_Php_Oracle_Symfony_Doctrine Orm - Fatal编程技术网

Php 使用命令将文件另存为BLOB

Php 使用命令将文件另存为BLOB,php,oracle,symfony,doctrine-orm,Php,Oracle,Symfony,Doctrine Orm,我将Symfony2与Doctrine 2.2.2和Oracle数据库一起使用。我想将文件另存为Oracle数据库中的BLOB。我为条令写了一个肋骨类型,有一个斑点类型。看起来是这样的: class Blob extends Type { const BLOB = 'blob'; public function convertToPHPValue($value, AbstractPlatform $platform) { return (is_resource($value)) ?

我将Symfony2与Doctrine 2.2.2和Oracle数据库一起使用。我想将文件另存为Oracle数据库中的BLOB。我为条令写了一个肋骨类型,有一个斑点类型。看起来是这样的:

class Blob extends Type
{
const BLOB = 'blob';


public function convertToPHPValue($value, AbstractPlatform $platform)
{
    return (is_resource($value)) ? stream_get_contents($value) : $value;
}

public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
    return 'BLOB';
}

public function getBindingType() {
    return \PDO::PARAM_LOB;
}

public function getName()
{
    return self::BLOB;
}
}
保存文件的实体如下所示:

<?php

class Document
{
/**
 * @var integer $id
 */
private $id;

/**
 * @var file $file
 */
private $file;

/**
 * Get id
 *
 * @return integer 
 */
public function getId()
{
    return $this->id;
}

/**
 * Set file
 *
 * @param blob $file
 */
public function setFile($file)
{
    $this->file = $file;
}

/**
 * Get file
 *
 * @return blob 
 */
public function getFile()
{
    return $this->file;
}
}

似乎$file变量不是资源

你可以试试这个:

public function convertToPHPValue($value, AbstractPlatform $platform)
{
    return is_file($value) ? file_get_contents($value) : $value;
}

似乎是条令2.2中的blob类型,此处条令\DBAL\Types\BlobType

不,这也不起作用。Doctrine只保存临时上载文件的路径,并在我想从数据库下载时返回该路径。您确定您的blob类型已正确注册和使用吗?您找到了解决方案吗?