我試圖讓與「Destinataire」所有門票等於「孔特」:Symfony和教義要求
$ret = $repository->findByDestinataires($compte->getId());
我的問題是,我得到一個錯誤:
An exception occurred while executing 'SELECT t0.id AS id_1, t0.Titre AS Titre_2, t0.DateCreation AS DateCreation_3, t0.DateButoire AS DateButoire_4, t0.DateFin AS DateFin_5, t0.Priorite AS Priorite_6, t0.Commentaire AS Commentaire_7, t0.Statut AS Statut_8, t0.emeteur_id AS emeteur_id_9, t0.client_id AS client_id_10 FROM ticket t0 WHERE ticket_compte.compte_id = ?' with params [1]:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ticket_compte.compte_id' in 'where clause'
我有兩個表是這樣的:
孔特:
namespace CommonBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Compte
*
* @ORM\Table(name="compte")
* @ORM\Entity(repositoryClass="CommonBundle\Repository\CompteRepository")
*/
class Compte
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
public $id;
/**
* @var string
*
* @ORM\Column(name="Nom", type="string", length=80)
*/
public $nom;
/**
* @var string
*
* @ORM\Column(name="Prenom", type="string", length=80)
*/
public $prenom;
/**
* @var string
*
* @ORM\Column(name="Fonction", type="string", length=80)
*/
public $fonction;
/**
* @var string
*
* @Assert\NotBlank()
* @ORM\Column(name="Pseudo", type="string", length=80)
*/
public $pseudo;
/**
* @var string
*
* @Assert\NotBlank()
* @ORM\Column(name="MotDePasse", type="string", length=80)
*/
public $motDePasse;
/**
* @ORM\ManyToOne(targetEntity="CommonBundle\Entity\Profil", cascade={"persist"})
* @ORM\JoinColumn(nullable=false)
*/
public $profil;
/**
* @ORM\ManyToMany(targetEntity="CommonBundle\Entity\Ticket", cascade={"persist"})
*/
public $tickets;
}
門票:
namespace CommonBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Ticket
*
* @ORM\Table(name="ticket")
* @ORM\Entity(repositoryClass="CommonBundle\Repository\TicketRepository")
*/
class Ticket
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
public $id;
/**
* @var string
*
* @ORM\Column(name="Titre", type="string", length=80)
*/
public $titre;
/**
* @var \DateTime
*
* @ORM\Column(name="DateCreation", type="datetimetz")
*/
public $dateCreation;
/**
* @var \DateTime
*
* @ORM\Column(name="DateButoire", type="datetimetz")
*/
public $dateButoire;
/**
* @var \DateTime
*
* @ORM\Column(name="DateFin", type="datetimetz", nullable=true)
*/
public $dateFin;
/**
* @var int
*
* @ORM\Column(name="Priorite", type="integer")
*/
public $priorite;
/**
* @var string
*
* @ORM\Column(name="Commentaire", type="text")
*/
public $commentaire;
/**
* @var int
*
* @ORM\Column(name="Statut", type="integer")
*/
public $statut;
/**
* @ORM\ManyToOne(targetEntity="CommonBundle\Entity\Compte", cascade={"persist"})
* @ORM\JoinColumn(nullable=false)
*/
public $emeteur;
/**
* @ORM\ManyToMany(targetEntity="CommonBundle\Entity\Compte", cascade={"persist"})
* @ORM\JoinColumn(nullable=true)
*/
public $destinataires;
/**
* @ORM\ManyToOne(targetEntity="CommonBundle\Entity\Client")
* @ORM\JoinColumn(nullable=true)
*/
public $client;
}
還有鏈接:
compte_ticket //爲 「emeteure」
- > TICKET_ID compte_id
ticket_compte //爲 「destinataires」
- > ticket_id compte_id
我試過了直接在服務器上發出相同的請求,並得到相同的錯誤。 它是錯誤的PHP代碼? 或者,也許實體...
信息:
我沒有把所有的GET /從孔特或訂機票的目的。如果需要,我會編輯。
完美的答案。 –