出于某种原因,每当我使用php app/console doctrine:schema:update --dump-sql
时,它都会给我这个错误:
[ReflectionException]
Property sava\UserBundle\Entity\User::$Tickets does not exist
通常我首先创建orm,然后使用doctrine生成:generate:entities,我的问题是每当我尝试更新架构时,它都会给我这个错误,我已经尝试过了:
我没有想法。
错误这是我的依赖。
User.Orm:
sava\UserBundle\Entity\User:
type: entity
table: User
fields:
id:
id: true
type: integer
generator:
strategy: AUTO
nombreCliente:
type: string
length: 200
fixed: false
nullable: false
column: nombre_cliente
rifCedula:
type: string
length: 40
fixed: false
nullable: false
column: rif_cedula
telefono:
type: string
length: 30
fixed: false
nullable: true
celular:
type: string
length: 30
fixed: false
nullable: true
direccion:
type: string
length: 250
fixed: false
nullable: true
oneToMany:
Tickets:
targetEntity: sava\SoporteBundle\Entity\TblTicket
mappedBy: idUser
cascade: ["persist", "remove"]
lifecycleCallbacks: { }
Ticket.Orm。
sava\SoporteBundle\Entity\TblTicket:
type: entity
table: tbl_ticket
fields:
id:
type: integer
id: true
generator:
strategy: AUTO
titulo:
type: string
length: '80'
contenido:
type: text
isClosed:
type: boolean
fecha:
type: date
oneToMany:
respuestas:
targetEntity: sava\SoporteBundle\Entity\TblRespuesta
mappedBy: ticket
cascade: ["persist", "remove"]
oneToOne:
idUser:
targetEntity: sava\UserBundle\Entity\User
inversedBy: Tickets
#nullable: true
joinColumn:
name: id_user
referencedColumnName: id
lifecycleCallbacks: { }
票证实体(为清晰起见,删除了一些不相关的字段):
<?php
namespace sava\SoporteBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* TblTicket
*/
class TblTicket
{
/**
* @var integer
*/
private $id;
/**
* @var \Doctrine\Common\Collections\Collection
*/
public function __construct()
{
$this->respuestas = new \Doctrine\Common\Collections\ArrayCollection();
}
protected $idUser;
public function setIdUser(\sava\UserBundle\Entity\User $idUser = null)
{
$this->idUser = $idUser;
return $this;
}
/**
* Get idUser
*
* @return \sava\UserBundle\Entity\User
*/
public function getIdUser()
{
return $this->idUser;
}
}
>
这是我的fos / user / bundle扩展的故障单实体(为清晰起见,删除了一些字段):
namespace sava\UserBundle\Entity;
use FOS\UserBundle\Model\User as BaseUser;
/**
* user
*
*/
class User extends BaseUser
{
public function __construct()
{
parent::__construct();
//$this->User = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* @var \Doctrine\Common\Collections\Collection
*/
protected $Tickets;
/**
* Add Tickets
*
* @param \sava\SoporteBundle\Entity\TblTicket $tickets
* @return User
*/
public function addTicket(\sava\SoporteBundle\Entity\TblTicket $tickets)
{
$this->Tickets[] = $tickets;
return $this;
}
/**
* Remove Tickets
*
* @param \sava\SoporteBundle\Entity\TblTicket $tickets
*/
public function removeTicket(\sava\SoporteBundle\Entity\TblTicket $tickets)
{
$this->Tickets->removeElement($tickets);
}
/**
* Get Tickets
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getTickets()
{
return $this->Tickets;
}
}
答案 0 :(得分:1)
没关系,我正在测试userbundle的旧捆绑包含一个实体,它以某种方式被学说作为目标。删除旧捆绑及其工作正常。
如果您遇到此问题,请检查捆绑包是否有额外的不需要的实体或命名空间。
答案 1 :(得分:0)
您必须先更新您的实体:
php app/console doctrine:generate:entities [YourBundle:YouEntity]