2014-05-14 5 views
0

는 내가하려고 할 때생성자 클래스에서 ID 값을 초기화하고 doctrine에서의 las ID 자동 증가를 얻는 방법, symfony2?

클래스 Prueba {

/** 
* @var integer $id 
* 
* @ORM\Column(name="`id`", type="integer") 
* @ORM\Id 
* @ORM\GeneratedValue(strategy="AUTO") 
*/ 
protected $id; 

는하지만,이 필드 ID를 자동 증가와 클래스가 있습니다

public function __construct() 
    { 


     $this->entorno = new Entorno('MSU',$this->id); 

    } 

this-> ID가 1로 초기화되지 않습니다 및 NULL입니다

원하는 항목 :

첫 번째 경우 새로운 Prueba() 또는 교리 prueba 다른

$this->id=get the last ID from table Prueba in doctrine. 

$this->id = 1 

내가 어떻게 할 수있는 비어?

답변

0

유감스럽게도이 클래스를 내 클래스에 포함하는 것을 잊어 버렸습니다. * @ORM \ JoinColumn (name = "prueba_id", referencedColumnName = "id")