Symfony 2: сущности доктрины не обновляются

0

Я очень новичок в Symfony 2.0 и доктрине. У меня есть generete мое сущность ссылается на поваренную книгу "Как создать сущности из существующей базы данных" мое отношение: клиент имеет много выплат по выплате одному клиенту

Объект: Client.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;
    }
}

Объект: Payement.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 в моем ClientAdmin: после добавления в Client.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

обновить настройки и настройки

НО, а получатели и наборы выплат не генерируются в классе клиента

Теги:
doctrine
entities

2 ответа

0
Лучший ответ

разрешено путем выполнения перед генерированием объектов

php app/console doctrine:cache:clear-metadata 

любой может объяснить, кто?

0

Вы уверены, что правильный путь к вашим сущностям?

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 
  • 0
    если я удаляю все функции, получаю и устанавливаю php app / console доктрину: generate: entity Auto \ EcoleBundle \ Entity \ Client генерирует все функции только для получения и набора платежей, и если я переименую или удаляю culunm после запуска, генерируем сущности старое имя Culunm показывает с функцией получения и настройки

Ещё вопросы

Сообщество Overcoder
Наверх
Меню