Symfony 2:教义实体未更新


Symfony 2 : doctrine entities not updated

我对Symfony 2.0和教义很陌生。我有我的实体参考食谱"如何从现有数据库生成实体"我的关系船 :客户有很多付款向一位客户付款

实体 : 客户端.php

<?php
   namespace Auto'EcoleBundle'Entity;
   use Doctrine'ORM'Mapping as ORM;
       /**
        * Client
        *
        * @ORM'Table(name="client", indexes={@ORM'Index(name="fk_client_delegation1_idx", columns={"delegation_id"})})
        * @ORM'Entity
        */
     class Client
       {
        /**
         * @var string
         *
         * @ORM'Column(name="nom", type="string", length=45, nullable=false)
         */

  private $nom;
    /**
     * @var 'DateTime
     *
     * @ORM'Column(name="date_nais", type="date", nullable=true)
     */
    private $dateNais;
    /**
     * @var string
     *
     * @ORM'Column(name="profession", type="string", length=45, nullable=true)
     */
    private $profession;
    /**
     * @var string
     *
     * @ORM'Column(name="passport_num", type="string", length=45, nullable=true)
     */
    private $passportNum;
    /**
     * @var string
     *
     * @ORM'Column(name="cin_num", type="string", length=45, nullable=true)
     */
    private $cinNum;
    /**
     * @var 'DateTime
     *
     * @ORM'Column(name="cin_date", type="date", nullable=true)
     */
    private $cinDate;
    /**
     * @var string
     *
     * @ORM'Column(name="adresse", type="string", length=100, nullable=true)
     */
    private $adresse;
    /**
     * @var string
     *
     * @ORM'Column(name="code_postal", type="string", length=45, nullable=true)
     */
    private $codePostal;
    /**
     * @var boolean
     *
     * @ORM'Column(name="code", type="boolean", nullable=true)
     */
    private $code;
    /**
     * @var string
     *
     * @ORM'Column(name="tel", type="string", length=45, nullable=true)
     */
    private $tel;
    /**
     * @var string
     *
     * @ORM'Column(name="fax", type="string", length=45, nullable=true)
     */
    private $fax;
    /**
     * @var string
     *
     * @ORM'Column(name="email", type="string", length=50, nullable=true)
     */
    private $email;
    /**
     * @var integer
     *
     * @ORM'Column(name="id", type="integer")
     * @ORM'Id
     * @ORM'GeneratedValue(strategy="IDENTITY")
     */
    private $id;
    /**
     * @var 'Auto'EcoleBundle'Entity'Delegation
     *
     * @ORM'ManyToOne(targetEntity="Auto'EcoleBundle'Entity'Delegation")
     * @ORM'JoinColumns({
     *   @ORM'JoinColumn(name="delegation_id", referencedColumnName="id")
     * })
     */
    private $delegation;
    /**
     * @var 'Doctrine'Common'Collections'Collection
     *
     * @ORM'ManyToMany(targetEntity="Auto'EcoleBundle'Entity'ExamenCode", inversedBy="client")
     * @ORM'JoinTable(name="client_has_examen_code",
     *   joinColumns={
     *     @ORM'JoinColumn(name="client_id", referencedColumnName="id")
     *   },
     *   inverseJoinColumns={
     *     @ORM'JoinColumn(name="examen_code_id", referencedColumnName="id")
     *   }
     * )
     */
    private $examenCode;
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->examenCode = new 'Doctrine'Common'Collections'ArrayCollection();
    }

    /**
     * Set nom
     *
     * @param string $nom
     * @return Client
     */
    public function setNom($nom)
    {
        $this->nom = $nom;
        return $this;
    }
    /**
     * Get nom
     *
     * @return string 
     */
    public function getNom()
    {
        return $this->nom;
    }
    /**
     * Set dateNais
     *
     * @param 'DateTime $dateNais
     * @return Client
     */
    public function setDateNais($dateNais)
    {
        $this->dateNais = $dateNais;
        return $this;
    }
    /**
     * Get dateNais
     *
     * @return 'DateTime 
     */
    public function getDateNais()
    {
        return $this->dateNais;
    }
    /**
     * Set profession
     *
     * @param string $profession
     * @return Client
     */
    public function setProfession($profession)
    {
        $this->profession = $profession;
        return $this;
    }
    /**
     * Get profession
     *
     * @return string 
     */
    public function getProfession()
    {
        return $this->profession;
    }
    /**
     * Set passportNum
     *
     * @param string $passportNum
     * @return Client
     */
    public function setPassportNum($passportNum)
    {
        $this->passportNum = $passportNum;
        return $this;
    }
    /**
     * Get passportNum
     *
     * @return string 
     */
    public function getPassportNum()
    {
        return $this->passportNum;
    }
    /**
     * Set cinNum
     *
     * @param string $cinNum
     * @return Client
     */
    public function setCinNum($cinNum)
    {
        $this->cinNum = $cinNum;
        return $this;
    }
    /**
     * Get cinNum
     *
     * @return string 
     */
    public function getCinNum()
    {
        return $this->cinNum;
    }
    /**
     * Set cinDate
     *
     * @param 'DateTime $cinDate
     * @return Client
     */
    public function setCinDate($cinDate)
    {
        $this->cinDate = $cinDate;
        return $this;
    }
    /**
     * Get cinDate
     *
     * @return 'DateTime 
     */
    public function getCinDate()
    {
        return $this->cinDate;
    }
    /**
     * Set adresse
     *
     * @param string $adresse
     * @return Client
     */
    public function setAdresse($adresse)
    {
        $this->adresse = $adresse;
        return $this;
    }
    /**
     * Get adresse
     *
     * @return string 
     */
    public function getAdresse()
    {
        return $this->adresse;
    }
    /**
     * Set codePostal
     *
     * @param string $codePostal
     * @return Client
     */
    public function setCodePostal($codePostal)
    {
        $this->codePostal = $codePostal;
        return $this;
    }
    /**
     * Get codePostal
     *
     * @return string 
     */
    public function getCodePostal()
    {
        return $this->codePostal;
    }
    /**
     * Set code
     *
     * @param boolean $code
     * @return Client
     */
    public function setCode($code)
    {
        $this->code = $code;
        return $this;
    }
    /**
     * Get code
     *
     * @return boolean 
     */
    public function getCode()
    {
        return $this->code;
    }
    /**
     * Set tel
     *
     * @param string $tel
     * @return Client
     */
    public function setTel($tel)
    {
        $this->tel = $tel;
        return $this;
    }
    /**
     * Get tel
     *
     * @return string 
     */
    public function getTel()
    {
        return $this->tel;
    }
    /**
     * Set fax
     *
     * @param string $fax
     * @return Client
     */
    public function setFax($fax)
    {
        $this->fax = $fax;
        return $this;
    }
    /**
     * Get fax
     *
     * @return string 
     */
    public function getFax()
    {
        return $this->fax;
    }
    /**
     * Set email
     *
     * @param string $email
     * @return Client
     */
    public function setEmail($email)
    {
        $this->email = $email;
        return $this;
    }
    /**
     * Get email
     *
     * @return string 
     */
    public function getEmail()
    {
        return $this->email;
    }
    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }
    /**
     * Set delegation
     *
     * @param 'Auto'EcoleBundle'Entity'Delegation $delegation
     * @return Client
     */
    public function setDelegation('Auto'EcoleBundle'Entity'Delegation $delegation = null)
    {
        $this->delegation = $delegation;
        return $this;
    }
    /**
     * Get delegation
     *
     * @return 'Auto'EcoleBundle'Entity'Delegation 
     */
    public function getDelegation()
    {
        return $this->delegation;
    }
    /**
     * Add examenCode
     *
     * @param 'Auto'EcoleBundle'Entity'ExamenCode $examenCode
     * @return Client
     */
    public function addExamenCode('Auto'EcoleBundle'Entity'ExamenCode $examenCode)
    {
        $this->examenCode[] = $examenCode;
        return $this;
    }
    /**
     * Remove examenCode
     *
     * @param 'Auto'EcoleBundle'Entity'ExamenCode $examenCode
     */
    public function removeExamenCode('Auto'EcoleBundle'Entity'ExamenCode $examenCode)
    {
        $this->examenCode->removeElement($examenCode);
    }
    /**
     * Get examenCode
     *
     * @return 'Doctrine'Common'Collections'Collection 
     */
    public function getExamenCode()
    {
        return $this->examenCode;
    }
}

实体:P ayement.php

<?php
namespace Auto'EcoleBundle'Entity;
use Doctrine'ORM'Mapping as ORM;
/**
 * Payement
 *
 * @ORM'Table(name="payement", indexes={@ORM'Index(name="fk_payement_client1_idx", columns={"client_id"}), @ORM'Index(name="fk_payement_payement_type1_idx", columns={"payement_type_id"}), @ORM'Index(name="fk_payement_rebrique1_idx", columns={"rebrique_id"}), @ORM'Index(name="fk_payement_banque1_idx", columns={"banque_id"})})
 * @ORM'Entity
 */
class Payement
{
    /**
     * @var float
     *
     * @ORM'Column(name="montant", type="float", precision=10, scale=0, nullable=true)
     */
    private $montant;
    /**
     * @var 'DateTime
     *
     * @ORM'Column(name="date_payement", type="date", nullable=true)
     */
    private $datePayement;
    /**
     * @var string
     *
     * @ORM'Column(name="remarque", type="string", length=45, nullable=true)
     */
    private $remarque;
    /**
     * @var string
     *
     * @ORM'Column(name="num_cheque", type="string", length=45, nullable=true)
     */
    private $numCheque;
    /**
     * @var integer
     *
     * @ORM'Column(name="id", type="integer")
     * @ORM'Id
     * @ORM'GeneratedValue(strategy="IDENTITY")
     */
    private $id;
    /**
     * @var 'Auto'EcoleBundle'Entity'Banque
     *
     * @ORM'ManyToOne(targetEntity="Auto'EcoleBundle'Entity'Banque")
     * @ORM'JoinColumns({
     *   @ORM'JoinColumn(name="banque_id", referencedColumnName="id")
     * })
     */
    private $banque;
    /**
     * @var 'Auto'EcoleBundle'Entity'PayementRebrique
     *
     * @ORM'ManyToOne(targetEntity="Auto'EcoleBundle'Entity'PayementRebrique")
     * @ORM'JoinColumns({
     *   @ORM'JoinColumn(name="rebrique_id", referencedColumnName="id")
     * })
     */
    private $rebrique;
    /**
     * @var 'Auto'EcoleBundle'Entity'PayementType
     *
     * @ORM'ManyToOne(targetEntity="Auto'EcoleBundle'Entity'PayementType")
     * @ORM'JoinColumns({
     *   @ORM'JoinColumn(name="payement_type_id", referencedColumnName="id")
     * })
     */
    private $payementType;
    /**
     * @var 'Auto'EcoleBundle'Entity'Client
     *
     * @ORM'ManyToOne(targetEntity="Auto'EcoleBundle'Entity'Client")
     * @ORM'JoinColumns({
     *   @ORM'JoinColumn(name="client_id", referencedColumnName="id")
     * })
     */
    private $client;

    /**
     * Set montant
     *
     * @param float $montant
     * @return Payement
     */
    public function setMontant($montant)
    {
        $this->montant = $montant;
        return $this;
    }
    /**
     * Get montant
     *
     * @return float 
     */
    public function getMontant()
    {
        return $this->montant;
    }
    /**
     * Set datePayement
     *
     * @param 'DateTime $datePayement
     * @return Payement
     */
    public function setDatePayement($datePayement)
    {
        $this->datePayement = $datePayement;
        return $this;
    }
    /**
     * Get datePayement
     *
     * @return 'DateTime 
     */
    public function getDatePayement()
    {
        return $this->datePayement;
    }
    /**
     * Set remarque
     *
     * @param string $remarque
     * @return Payement
     */
    public function setRemarque($remarque)
    {
        $this->remarque = $remarque;
        return $this;
    }
    /**
     * Get remarque
     *
     * @return string 
     */
    public function getRemarque()
    {
        return $this->remarque;
    }
    /**
     * Set numCheque
     *
     * @param string $numCheque
     * @return Payement
     */
    public function setNumCheque($numCheque)
    {
        $this->numCheque = $numCheque;
        return $this;
    }
    /**
     * Get numCheque
     *
     * @return string 
     */
    public function getNumCheque()
    {
        return $this->numCheque;
    }
    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }
    /**
     * Set banque
     *
     * @param 'Auto'EcoleBundle'Entity'Banque $banque
     * @return Payement
     */
    public function setBanque('Auto'EcoleBundle'Entity'Banque $banque = null)
    {
        $this->banque = $banque;
        return $this;
    }
    /**
     * Get banque
     *
     * @return 'Auto'EcoleBundle'Entity'Banque 
     */
    public function getBanque()
    {
        return $this->banque;
    }
    /**
     * Set rebrique
     *
     * @param 'Auto'EcoleBundle'Entity'PayementRebrique $rebrique
     * @return Payement
     */
    public function setRebrique('Auto'EcoleBundle'Entity'PayementRebrique $rebrique = null)
    {
        $this->rebrique = $rebrique;
        return $this;
    }
    /**
     * Get rebrique
     *
     * @return 'Auto'EcoleBundle'Entity'PayementRebrique 
     */
    public function getRebrique()
    {
        return $this->rebrique;
    }
    /**
     * Set payementType
     *
     * @param 'Auto'EcoleBundle'Entity'PayementType $payementType
     * @return Payement
     */
    public function setPayementType('Auto'EcoleBundle'Entity'PayementType $payementType = null)
    {
        $this->payementType = $payementType;
        return $this;
    }
    /**
     * Get payementType
     *
     * @return 'Auto'EcoleBundle'Entity'PayementType 
     */
    public function getPayementType()
    {
        return $this->payementType;
    }
    /**
     * Set client
     *
     * @param 'Auto'EcoleBundle'Entity'Client $client
     * @return Payement
     */
    public function setClient('Auto'EcoleBundle'Entity'Client $client = null)
    {
        $this->client = $client;
        return $this;
    }
    /**
     * Get client
     *
     * @return 'Auto'EcoleBundle'Entity'Client 
     */
    public function getClient()
    {
        return $this->client;
    }
}

我想在我的客户端管理员中使用sonata_type_collection:添加客户端后.php

        /**
         * @ORM'OneToMany(targetEntity="Auto'EcoleBundle'Entity'Payement", cascade={"persist", "remove"}, mappedBy="client")
         * 
         */
private $payements;

            $this->payements = new 'Doctrine'Common'Collections'ArrayCollection(); in __constact() function

并更新Payement.php :

    /**
     * @var 'Auto'EcoleBundle'Entity'Client
     *
     * @ORM'ManyToOne(targetEntity="Auto'EcoleBundle'Entity'Client", inversedBy="payements")
     */
    private $client;

然后运行后:

php app/console doctrine:generate:entities AutoEcoleBundle:Client
php app/console doctrine:generate:entities AutoEcoleBundle:Payement

更新我的获取和设置

但是在客户端类中不会生成付款的获取和集合

你确定这是通往你的实体的正确途径吗?

php app/console doctrine:generate:entities AutoEcoleBundle:Client
php app/console doctrine:generate:entities AutoEcoleBundle:Payement

如果路径不正确,您应该在这些之后出现错误。

尝试添加正确的(在您的文件夹中检查它,不确定它是否正确(:

php app/console doctrine:generate:entities Auto'EcoleBundle'Entity'Client
php app/console doctrine:generate:entities Auto'EcoleBundle'Entity'Payement 

通过在生成实体之前运行来解决

php app/console doctrine:cache:clear-metadata 

谁能解释一下哇?