[英]I can't update my database. symfony php database doctrine
我嘗試使用學說來管理我的數據庫。
我有兩個實體,三個小時后我成功添加了模型。 當我對實體voiture
編碼時,它會不斷顯示基礎已更新,並且沒有更改。
我的模型代碼:
<?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;
}
}
和我的語音代碼:
<?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;
}
}
這是我得到的錯誤:
錯誤:沒有更新-您的數據庫已經與當前實體元數據同步。
您對id字段有兩個注釋。 刪除其中之一:
/**
*@ORM\Id
*@ORM\Column(type="integer")
*/
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
可能是因為將ORM
用於Entity注釋之后,您正在導入它。
嘗試將您的Entity注釋放在下面,使用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;
/.../
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.