首页 > 解决方案 > 数据库中缺少属性

问题描述

当我使用:s 学说:模式:更新 - 强制在我的数据库中创建我的表时,我只得到 id 属性,其他都没有

S 学说:数据库:创建 s 学说:生成:form ClubBundle:Club 我没有接触过我使用过的实体 Club.php 文件我在表中获得的唯一属性只有 id!

<?php

    namespace ClubBundle\Entity;

    use Doctrine\ORM\Mapping as ORM;

      /**
      * Club
      *
      * @ORM\Table(name="club")
      * @ORM\Entity(repositoryClass="ClubBundle\Repository\ClubRepository")
       */
      class Club
     {
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

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

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

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

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

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

    /**
     * Set nom
     *
     * @param string $nom
     *
     * @return Club
     */
    public function setNom($nom)
    {
        $this->nom = $nom;

        return $this;
    }

    /**
     * Get nom
     *
     * @return string
     */
    public function getNom()
    {
        return $this->nom;
    }

    /**
     * Set description
     *
     * @param string $description
     *
     * @return Club
     */
    public function setDescription($description)
    {
        $this->description = $description;

        return $this;
    }

    /**
     * Get description
     *
     * @return string
     */
    public function getDescription()
    {
        return $this->description;
    }

    /**
     * Set adresse
     *
     * @param string $adresse
     *
     * @return Club
     */
    public function setAdresse($adresse)
    {
        $this->adresse = $adresse;

        return $this;
    }

    /**
     * Get adresse
     *
     * @return string
     */
    public function getAdresse()
    {
        return $this->adresse;
    }

    /**
     * Set domaine
     *
     * @param string $domaine
     *
     * @return Club
     */
    public function setDomaine($domaine)
    {
        $this->domaine = $domaine;

        return $this;
    }

    /**
     * Get domaine
     *
     * @return string
     */
    public function getDomaine()
    {
        return $this->domaine;
    }
}

标签: symfonydoctrine

解决方案


尝试

php bin/console cache:clear 

和这个:

php bin/console doctrine:schema:update --complete --force

或者

php bin/console doctrine:schema:update --force

如果你使用 symfony 4 试试这个

php bin/console make:migration

那么这个

php bin/console doctrine:migrations:migrate

推荐阅读