2016-11-27 1 views
0

나는 doctrine으로 데이터베이스를 관리하려고한다.데이터베이스를 업데이트 할 수 없습니다. symfony php database doctrine

나는 두 개의 엔티티를 가지고 있는데, 나는 3 시간 후에 모드를 추가하는데 성공했다. 내 엔터티 voiture을 코딩하면베이스가 업데이트되고 변경이 없음을 계속 보여줍니다.

내 modele 코드 :

<?php 
/** 
* Created by PhpStorm. 
* User: jamel_pc 
* Date: 2016-11-27 
* Time: 9:16 PM 
*/ 

namespace ParcBundle\Entity; 
use Doctrine\ORM\Mapping as ORM; 

/** 
* Class Modele 
* @package ParcBundle\Entity 
* 
* @ORM\Entity 
* @ORM\Table(name="Modele") 
*/ 
class Modele{ 
/** 
*@ORM\Id 
*@ORM\Column(type="integer") 
*/ 
private $id; 
/** 
* @ORM\Column(type="string",length=255) 
* 
*/ 

private $Libelle; 
/** 
* @ORM\Column(type="string",length=255) 
*/ 

private $Pays; 
/** 
* @ORM\Column(type="string",length=255) 
*/ 

/** 
* @return mixed 
*/ 
public function getLibelle() 
{ 
    return $this->Libelle; 
} 

/** 
* @param mixed $Libelle 
*/ 
public function setLibelle($Libelle) 
{ 
    $this->Libelle = $Libelle; 
} 

/** 
* @return mixed 
*/ 
public function getId() 
{ 
    return $this->id; 
} 

/** 
* @param mixed $id 
*/ 
public function setId($id) 
{ 
    $this->id = $id; 
} 

/** 
* @return mixed 
*/ 
public function getPays() 
{ 
    return $this->Pays; 
} 

/** 
* @param mixed $Pays 
*/ 
public function setPays($Pays) 
{ 
    $this->Pays = $Pays; 
} 
} 

내 voiture 코드 :

<?php 
/** 
* Created by PhpStorm. 
* User: jamel_pc 
* Date: 2016-11-27 
* Time: 11:10 PM 
*/ 

/** 
* Class voiture 
* @package ParcBundle\Entity 
* 
* @ORM\Entity 
* @ORM\Table(name="Voiture") 
*/ 

namespace ParcBundle\Entity; 
use Doctrine\ORM\Mapping as ORM; 


class voiture 
{ 

/** 
*@ORM\Id 
*@ORM\Column(type="integer") 
*/ 

/** 
* @var integer 
* 
* @ORM\Column(name="id", type="integer") 
* @ORM\Id 
* @ORM\GeneratedValue(strategy="AUTO") 
*/ 
private $id; 
/** 
* @ORM\Column(type="string",length=255) 
* 
*/ 

private $Serie; 
/** 
* @ORM\Column(type="datetime",length=255) 
*/ 

private $DateMiseCirculation; 
/** 
* @ORM\Column(type="string",length=255) 
*/ 
private $Marque; 

/** 
* @ORM\ManyToOne(targetEntity="ParcBundle\Entity\Modele") 
* @ORM\JoinColumn(name="id", referencedColumnName="id"); 
*/ 
private $modele; 

/** 
* @return mixed 
*/ 

public function getId() 
{ 
    return $this->id; 
} 

/** 
* @param mixed $id 
*/ 
public function setId($id) 
{ 
    $this->id = $id; 
} 
/** 
* @return mixed 
*/ 

public function getModele() 
{ 
    return $this->modele; 
} 

/** 
* @param mixed $modele 
*/ 
public function setModele($id) 
{ 
    $this->modele = $modele; 
} 


/** 
* @return mixed 
*/ 
public function getSerie() 
{ 
    return $this->Serie; 
} 

/** 
* @param mixed $Serie 
*/ 
public function setSerie($Serie) 
{ 
    $this->Serie = $Serie; 
} 

/** 
* @return mixed 
*/ 
public function getDateMiseCirculation() 
{ 
    return $this->DateMiseCirculation; 
} 

/** 
* @param mixed $DateMiseCirculation 
*/ 
public function setDateMiseCirculation($DateMiseCirculation) 
{ 
    $this->DateMiseCirculation = $DateMiseCirculation; 
} 

/** 
* @return mixed 
*/ 
public function getMarque() 
{ 
    return $this->Marque; 
} 

/** 
* @param mixed $Marque 
*/ 
public function setMarque($Marque) 
{ 
    $this->Marque = $Marque; 
} 



} 

입니다 오류가 나는 얻을 :

오류 : 아무것도 업데이트 - 데이터베이스가 이미 없다 현재 엔터티 메타 데이터 과 동기화됩니다.

+0

어쩌면 당신해야 클래스 선언이 아닌 별도의 주석. –

+0

현재 db 스키마는 무엇입니까? – sanandrl

+0

krauze : 나는 별개하지 않아야합니까? 어떻게 ? –

답변

0

당신이 당신의 엔티티 주석을 위해 그것을 사용한 후 ORM를 가져 오기 때문에 그것은있을 수 있습니다.

다음과 같이 사용 use Doctrine\ORM\Mapping as ORM 아래에 엔티티 주석을 넣어보십시오 :

<?php 
/** 
* Created by PhpStorm. 
* User: jamel_pc 
* Date: 2016-11-27 
* Time: 11:10 PM 
*/ 

namespace ParcBundle\Entity; 
use Doctrine\ORM\Mapping as ORM; 

/** 
* Class voiture 
* @package ParcBundle\Entity 
* 
* @ORM\Entity 
* @ORM\Table(name="Voiture") 
*/ 


class voiture 
{ 

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

/.../ 

} 
+0

덕분에 작동합니다 : D –

0

id 필드에는 두 개의 주석이 있습니다. 그 중 하나를 제거

/** 
*@ORM\Id 
*@ORM\Column(type="integer") 
*/ 

/** 
* @var integer 
* 
* @ORM\Column(name="id", type="integer") 
* @ORM\Id 
* @ORM\GeneratedValue(strategy="AUTO") 
*/ 
관련 문제