2017-12-12 11 views
-4
<?php 
namespace AppBundle\Entity; 
use Doctrine\Common\Collections\ArrayCollection; 
use Doctrine\ORM\Mapping as ORM; 
use AppBundle\Entity\Produits; 

/** 
* @ORM\Entity() 
* @ORM\Table(name="commandes") 
*/ 

class Commandes { 




    /** 
    * @ORM\Id 
    * @ORM\GeneratedValue(strategy="AUTO") 
    * @ORM\Column(name="N_commande",type="integer") 
    */ 

    private $id; 

    /** 
    * @ORM\ManyToOne(targetEntity="Clients") 
     * @ORM\JoinColumn(name="ID_client",nullable=false) 
    */ 

    protected $CodeClient; 

    /** 
    * @ORM\ManyToOne(targetEntity="Employes") 
     * @ORM\JoinColumn(name="N_employe",nullable=false) 
    */ 

    private $Num_employe; 

    /** 
    * @ORM\Column(name="Date_commande",type="date") 
    */ 

    private $Date_commande; 


    /** 
    * @ORM\Column(name="A_livrer_avant",type="date") 
    */ 

    private $AlivrerAvant; 

    /** 
    * @ORM\Column(name="Date_envoi",type="date") 
    */ 

    private $Date_envoi; 

    /** 
    * @ORM\ManyToOne(targetEntity="Messagers") 
     * @ORM\JoinColumn(name="N_messager",nullable=true) 
    */ 

    private $N_messager; 


    /** 
    * @ORM\Column(name="Port",type="string",length=30) 
    */ 

    private $Port; 

    /** 
    * @ORM\Column(name="Destinataire",type="string",length=50) 
    */ 

    private $Destinataire; 

    /** 
    * @ORM\Column(name="Adresse_livr",type="string",length=50) 
    */ 

    private $Adresse_livr; 

    /** 
    * @ORM\Column(name="Ville_livr",type="string",length=20) 
    */ 

    private $Ville_livr; 

    /** 
    * @ORM\Column(name="Region_livr",type="string",length=20) 
    */ 

    private $Region_livr; 

    /** 
    * @ORM\Column(name="Code_post_livr",type="string",length=20) 
    */ 

    private $Code_postal_livr; 

    /** 
    * @ORM\Column(name="Pays_livr",type="string",length=20) 
    */ 

    private $Pays_livr; 



    /** 
    * @var Produits 
    * @ORM\ManyToOne(targetEntity="Produits") 
    * @ORM\JoinColumn(name="id",nullable=true) 
    * 
    */ 
    public $Produits; 


    public function __construct() 
     { 
      $this->CodeClient = new ArrayCollection(); 
     } 


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

    /** 
    * Set dateCommande 
    * 
    * @param \DateTime $dateCommande 
    * 
    * @return Commandes 
    */ 
    public function setDateCommande($dateCommande) 
    { 
     $this->Date_commande = $dateCommande; 

     return $this; 
    } 

    /** 
    * Get dateCommande 
    * 
    * @return \DateTime 
    */ 
    public function getDateCommande() 
    { 
     return $this->Date_commande; 
    } 

    /** 
    * Set alivrerAvant 
    * 
    * @param \DateTime $alivrerAvant 
    * 
    * @return Commandes 
    */ 
    public function setAlivrerAvant($alivrerAvant) 
    { 
     $this->AlivrerAvant = $alivrerAvant; 

     return $this; 
    } 

    /** 
    * Get alivrerAvant 
    * 
    * @return \DateTime 
    */ 
    public function getAlivrerAvant() 
    { 
     return $this->AlivrerAvant; 
    } 

    /** 
    * Set dateEnvoi 
    * 
    * @param \DateTime $dateEnvoi 
    * 
    * @return Commandes 
    */ 
    public function setDateEnvoi($dateEnvoi) 
    { 
     $this->Date_envoi = $dateEnvoi; 

     return $this; 
    } 

    /** 
    * Get dateEnvoi 
    * 
    * @return \DateTime 
    */ 
    public function getDateEnvoi() 
    { 
     return $this->Date_envoi; 
    } 

    /** 
    * Set port 
    * 
    * @param string $port 
    * 
    * @return Commandes 
    */ 
    public function setPort($port) 
    { 
     $this->Port = $port; 

     return $this; 
    } 

    /** 
    * Get port 
    * 
    * @return string 
    */ 
    public function getPort() 
    { 
     return $this->Port; 
    } 

    /** 
    * Set destinataire 
    * 
    * @param string $destinataire 
    * 
    * @return Commandes 
    */ 
    public function setDestinataire($destinataire) 
    { 
     $this->Destinataire = $destinataire; 

     return $this; 
    } 

    /** 
    * Get destinataire 
    * 
    * @return string 
    */ 
    public function getDestinataire() 
    { 
     return $this->Destinataire; 
    } 

    /** 
    * Set adresseLivr 
    * 
    * @param string $adresseLivr 
    * 
    * @return Commandes 
    */ 
    public function setAdresseLivr($adresseLivr) 
    { 
     $this->Adresse_livr = $adresseLivr; 

     return $this; 
    } 

    /** 
    * Get adresseLivr 
    * 
    * @return string 
    */ 
    public function getAdresseLivr() 
    { 
     return $this->Adresse_livr; 
    } 

    /** 
    * Set villeLivr 
    * 
    * @param string $villeLivr 
    * 
    * @return Commandes 
    */ 
    public function setVilleLivr($villeLivr) 
    { 
     $this->Ville_livr = $villeLivr; 

     return $this; 
    } 

    /** 
    * Get villeLivr 
    * 
    * @return string 
    */ 
    public function getVilleLivr() 
    { 
     return $this->Ville_livr; 
    } 

    /** 
    * Set regionLivr 
    * 
    * @param string $regionLivr 
    * 
    * @return Commandes 
    */ 
    public function setRegionLivr($regionLivr) 
    { 
     $this->Region_livr = $regionLivr; 

     return $this; 
    } 

    /** 
    * Get regionLivr 
    * 
    * @return string 
    */ 
    public function getRegionLivr() 
    { 
     return $this->Region_livr; 
    } 

    /** 
    * Set codePostalLivr 
    * 
    * @param string $codePostalLivr 
    * 
    * @return Commandes 
    */ 
    public function setCodePostalLivr($codePostalLivr) 
    { 
     $this->Code_postal_livr = $codePostalLivr; 

     return $this; 
    } 

    /** 
    * Get codePostalLivr 
    * 
    * @return string 
    */ 
    public function getCodePostalLivr() 
    { 
     return $this->Code_postal_livr; 
    } 

    /** 
    * Set paysLivr 
    * 
    * @param string $paysLivr 
    * 
    * @return Commandes 
    */ 
    public function setPaysLivr($paysLivr) 
    { 
     $this->Pays_livr = $paysLivr; 

     return $this; 
    } 

    /** 
    * Get paysLivr 
    * 
    * @return string 
    */ 
    public function getPaysLivr() 
    { 
     return $this->Pays_livr; 
    } 

    /** 
    * Get codeClient 
    * 
    * @return \AppBundle\Entity\Clients 
    */ 
    public function getCodeClient() 
    { 
     return $this->CodeClient; 
    } 

    /** 
    * Set numEmploye 
    * 
    * @param \AppBundle\Entity\Employes $numEmploye 
    * 
    * @return Commandes 
    */ 
    public function setNumEmploye(\AppBundle\Entity\Employes $numEmploye = null) 
    { 
     $this->Num_employe = $numEmploye; 

     return $this; 
    } 

    /** 
    * Get numEmploye 
    * 
    * @return \AppBundle\Entity\Employes 
    */ 
    public function getNumEmploye() 
    { 
     return $this->Num_employe; 
    } 

    /** 
    * Set nMessager 
    * 
    * @param \AppBundle\Entity\Messagers $nMessager 
    * 
    * @return Commandes 
    */ 
    public function setNMessager(\AppBundle\Entity\Messagers $nMessager = null) 
    { 
     $this->N_messager = $nMessager; 

     return $this; 
    } 

    /** 
    * Get nMessager 
    * 
    * @return \AppBundle\Entity\Messagers 
    */ 
    public function getNMessager() 
    { 
     return $this->N_messager; 

    } 

    public function setProduits(\AppBundle\Entity\Produits $Produits = null) 
    { 
     $this->Produits = $Produits; 

     return $this; 
    } 

    /** 
    * Get nMessager 
    * 
    * @return \AppBundle\Entity\Produits 
    */ 
    public function getProduits() 
    { 
     return $this->Produits; 
    } 





    /** 
    * Set codeClient 
    * 
    * @param \AppBundle\Entity\Clients $codeClient 
    * 
    * @return Commandes 
    */ 
    public function setCodeClient(\AppBundle\Entity\Clients $codeClient = null) 
    { 
     $this->CodeClient = $codeClient; 

     return $this; 
    } 
    } 

**私は私のベース* あきらめ制御アップデートで私のスキームを更新したいCMDのエラーコード:PHPビン/コンソール教義:スキーマ:symfonyの更新問題

--force更新[教義\ DBAL \例外の\ DriverException] 'ALTER TABLEがFK_35D4282C9AF4514D制約FOREIGN KEY(ID_cli ENT)は、顧客(ID)を参照するADDコマンド' の実行中に例外が発生しました:

SQLSTATE [HY000]:一般的なエラー:1215が追加できません外部制約指数

[教義\ DBAL \ドライバ\のPDOException] SQLSTATE [HY000]:一般的なエラー:1215が制約を追加することはできません外部インデックス

[PDOException] SQLSTATE [HY000] :一般的なエラーは:1215は、制約に外部インデックスを追加することはできません

教義:スキーマ:更新[--complete] [--dump-SQL] [-f | --force] [--em [EM ]] [-h | --help] [-q | --quiet] [-v | VV | VV | --verbose] [-V | --version] [--ansi] [--no-ANSI] [-n | --no-相互作用] [-e | --env ENV] [--no-デバッグ] [ - ]

PS C:\ Users \ユーザーホーム\デスクトップ\ my_site>

+3

あなたは英語で質問してくださいhttps://stackoverflow.com/help/on-topic – aaa

+2

を尋ねる前に訪問したいと思うかもしれません。 –

答えて

0

あなたのテーブル "顧客" にidフィールドを持っていないようです。小切手 はよくクライアントクラスでの$ idがあなたも追加しました:

* @ORM\Column(name="id",type="integer") 
*/ 
private $id; 
0

問題は、あなたのテーブルの注文が空でないということで、既存の注文などの外部キーの顧客を追加することができますそれが論理的でない顧客ずに、突然SQL例外を起動します。

問題は、コマンドQUEラテーブルが空ではないですし、外部キーを追加した場合、最も古いコマンドは、顧客なしになりますので、それは論理的なSQLが例外をスローしないのです。