0
使用学说,我被介绍了以下错误:未知列类型“将varchar”
[2016-09-14 21:24:44] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\DBALException: "Unknown column type "varchar" requested. Any Doctrine type that you use has to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the known types with \Doctrine\DBAL\Types\Type::getTypeMap(). If this error occurs during database introspection then you might have forgot to register all database types for a Doctrine Type. Use AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement Type#getMappedDatabaseTypes(). If the type name is empty you might have a problem with the cache or forgot some mapping information." at /var/www/project/apps/ProjectName/trunk/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 114 {"exception":"[object] (Doctrine\\DBAL\\DBALException(code: 0): Unknown column type \"varchar\" requested. Any Doctrine type that you use has to be registered with \\Doctrine\\DBAL\\Types\\Type::addType(). You can get a list of all the known types with \\Doctrine\\DBAL\\Types\\Type::getTypeMap(). If this error occurs during database introspection then you might have forgot to register all database types for a Doctrine Type. Use AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement Type#getMappedDatabaseTypes(). If the type name is empty you might have a problem with the cache or forgot some mapping information. at /var/www/project/apps/ProjectName/trunk/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:114)"} []
相关类看起来如此
<?php
namespace Project\DBALBundle\Entity\Url;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as JMSS;
/**
* Profile
*
* @ORM\Table(name="Profile")
* @ORM\Entity(repositoryClass="Project\DBALBundle\Entity\Url\ProfileRepository")
*/
class ProfileRepository {
/**
* @var string $id
*
* @ORM\Column(name="id", type="integer", length=11, nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string $label
*
* @ORM\Column(name="label", type="string", length=50, nullable=false)
*/
private $label;
/**
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param string $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getLabel()
{
return $this->label;
}
/**
* @param string $label
*/
public function setLabel($label)
{
$this->label = $label;
}
public function __toString()
{
return $this->label;
}
}
有了上面的类和注释定义的映射,我收到错误。但是,如果我将字段private $label
更改为private $labelField
并更新关联的引用,则一切正常,数据按预期访问。
就我已经能够搜索,private $label
没有什么特别之处。它不是一个保留的关键字,我没有发现任何关于它的任何特别的内容,无论是使用PHP本身还是特定的Doctrine。那么为什么这会打破?
是的,没有意识到Symfony正在缓存它,或者至少在无数次其他更改后假定它的整个文件将在缓存中进行更新。此外,是的,它是一个传统的内部工具,有望在不久的将来被替换,所以我们坚持2.3。 –