dpw70180 2016-11-27 23:12
浏览 58
已采纳

我无法更新我的数据库。 symfony php数据库学说

I try to manage my database with doctrine.

I have two entities voiture et modele, I succeeded 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.

  • 写回答

2条回答 默认 最新

  • doujia7094 2016-11-28 07:47
    关注

    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;
    
     /.../
    
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!