我有一个Doctrine实体,其中包含统计信息条目的复合ID,如下所示:
/**
* @ORM\Table()
* @ORM\Entity(repositoryClass="WA\CoreBundle\Entity\StatRepository")
*
*/
class Stat
{
/**
* @ORM\Id
* @ORM\ManyToOne(targetEntity="Brand", inversedBy="stats")
*/
private $brand;
/**
* this field is auto filled. Users should not be able to define it themself.
* @ORM\Id
* @ORM\Column(type="string", length=16, columnDefinition="ENUM('a', 'b', 'c', 'd')")
*/
private $type;
/**
* @ORM\Id
* @ORM\Column(type="date")
*/
private $date;
/**
* @ORM\Column(type="array")
*/
private $value;
/**
* Set type
*
* @param string $type
* @return Stat
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* Get type
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* Set value
*
* @param string $value
* @return Stat
*/
public function setValue($value)
{
$this->value = $value;
return $this;
}
/**
* Get value
*
* @return string
*/
public function getValue()
{
return $this->value;
}
/**
* Set brand
*
* @param Brand $brand
* @return Stat
*/
public function setBrand(Brand $brand = null)
{
$this->brand = $brand;
return $this;
}
/**
* Get brand
*
* @return Brand
*/
public function getBrand()
{
return $this->brand;
}
/**
* Set date
*
* @param \DateTime $date
* @return Stat
*/
public function setDate($date)
{
$this->date = $date;
return $this;
}
/**
* Get date
*
* @return \DateTime
*/
public function getDate()
{
return $this->date;
}
}
每当我尝试插入新条目时,我都会收到此错误
Catchable Fatal Error:无法转换类DateTime的对象 串入 /..../vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php 第1359行
将日期字段退出索引允许我添加条目,但我想在索引中使用它。
有没有办法解决它?