php - Symfony 2 : doctrine entities not updated -
i'm new symfony 2.0 , doctrine. have generete entity refer cookbook 'how generate entities existing database' relation ship : client have many payement payement 1 client
entity : client.php
<?php namespace auto\ecolebundle\entity; use doctrine\orm\mapping 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; } /** * 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; } /** * 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; } /** * 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; } /** * 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; } /** * 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; } /** * 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; } /** * 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; } /** * 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; } /** * 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; } /** * 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; } /** * 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; } /** * email * * @return string */ public function getemail() { return $this->email; } /** * 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; } /** * 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); } /** * examencode * * @return \doctrine\common\collections\collection */ public function getexamencode() { return $this->examencode; } }
entity :payement.php
<?php namespace auto\ecolebundle\entity; use doctrine\orm\mapping 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; } /** * 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; } /** * 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; } /** * 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; } /** * numcheque * * @return string */ public function getnumcheque() { return $this->numcheque; } /** * 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; } /** * 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; } /** * 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; } /** * 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; } /** * client * * @return \auto\ecolebundle\entity\client */ public function getclient() { return $this->client; } }
i want use sonata_type_collection in clientadmin: after adding in client.php
/** * @orm\onetomany(targetentity="auto\ecolebundle\entity\payement", cascade={"persist", "remove"}, mappedby="client") * */ private $payements;
and
$this->payements = new \doctrine\common\collections\arraycollection(); in __constact() function
and updating payement.php :
/** * @var \auto\ecolebundle\entity\client * * @orm\manytoone(targetentity="auto\ecolebundle\entity\client", inversedby="payements") */ private $client;
then after runing :
php app/console doctrine:generate:entities autoecolebundle:client php app/console doctrine:generate:entities autoecolebundle:payement
to update getting , setting
but gets , sets of payement not generate in client class
are sure that's right path entities ?
php app/console doctrine:generate:entities autoecolebundle:client php app/console doctrine:generate:entities autoecolebundle:payement
you should error after if it's not right path.
try adding right 1 (check in folders, not sure if it's right):
php app/console doctrine:generate:entities auto\ecolebundle\entity\client php app/console doctrine:generate:entities auto\ecolebundle\entity\payement
Comments
Post a Comment