Jamel Mustapha Jamel Mustapha - 4 days ago 7
PHP Question

i can't update my database. symfony php database doctrine

I try to manage my database with doctrine.

I have two entities voiture et modele , I succeded to added modele after 3h . When I coded my entity

voiture
it keeps showing that the base is updated and there is no change.

my modele code :

<?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;
}
}


and my voiture code :

<?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;
}



}


This is the error I get :


error : Nothing to update - your database is already in sync with the
current entity metadata.

Answer

It might be because you are importing ORM after you have used it for your Entity annotation.

Try putting your Entity annotations below use use Doctrine\ORM\Mapping as ORM like this:

<?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;

 /.../

}
Comments