我有一个带字段ID自动增量的类
班普鲁巴{
/**
* @var integer $id
*
* @ORM\Column(name="`id`", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
但是当我尝试这个时:
public function __construct()
{
$this->entorno = new Entorno('MSU',$this->id);
}
this-> id未初始化为1且为NULL
我想要这个:
如果是第一个新的Prueba()或doctrine prueba是空的
$this->id = 1
其他
$this->id=get the last ID from table Prueba in doctrine.
我该怎么做?
答案 0 :(得分:0)
对不起,我忘了将它包含在我的Entorno类中:* @ORM \ JoinColumn(name =“prueba_id”,referencedColumnName =“id”)