我有疑问? 在syfony中有2个实体与多个联接表有多种关系。第一个是证书,第二个是mayag,连接表是certificate_mayag。证书有许多mayag与isAvailable,startDate,endDate字段。 mayag有很多证书 我想通过复选框表单呈现这种关系。表单由证书信息和mayag列表组成,带有复选框和startdate,enddate和isavailable字段。如何做到这个解决方案,哪一个是最好的开发方式?
<?php
/**
* Created by PhpStorm.
* User: Mendbayar
* Date: 12/8/13
* Time: 1:00 PM
*/
namespace Mnd\SrdBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="Mnd\SrdBundle\Repository\CertifyRepository")
* @ORM\Table(name="Certify")
*/
class Certify {
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", unique=true, length=50)
*/
protected $certificate_number;
/**
* @ORM\ManyToOne(targetEntity="CertificateOwner", inversedBy="certificates")
* @ORM\JoinColumn(name="owner_id", referencedColumnName="id")
*/
protected $owner;
/**
* @ORM\ManyToOne(targetEntity="Document", inversedBy="certificates")
* @ORM\JoinColumn(name="document_id", referencedColumnName="id")
*/
protected $document;
/**
* @ORM\ManyToOne(targetEntity="Action", inversedBy="certificates")
* @ORM\JoinColumn(name="action_id", referencedColumnName="id")
*/
protected $action;
/**
* @ORM\OneToMany(targetEntity="Extension", mappedBy="certify")
*/
protected $extensions;
/**
* @ORM\OneToMany(targetEntity="CertifyMayag", mappedBy="certify")
*/
protected $mayags;
}
<?php
/**
* Created by PhpStorm.
* User: Mendbayar
* Date: 12/22/13
* Time: 1:41 PM
*/
namespace Mnd\SrdBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="Mnd\SrdBundle\Repository\CertifyMayagRepository")
* @ORM\Table(name="certify_mayag")
*/
class CertifyMayag {
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\ManyToOne(targetEntity="Certify", inversedBy="certifyMayags")
* @ORM\JoinColumn(name="certifyId", referencedColumnName="id")
*/
protected $certify;
/**
* @ORM\ManyToOne(targetEntity="Mayag", inversedBy="MayagCertifies")
* @ORM\JoinColumn(name="mayagId", referencedColumnName="id")
*/
protected $mayag;
/**
* @ORM\Column(type="boolean")
*/
protected $isAvailable;
/**
* @ORM\Column(type="datetime")
*/
protected $startDate;
/**
* @ORM\Column(type="datetime")
*/
protected $endDate;
}
<?php
/**
* Created by PhpStorm.
* User: Mendbayar
* Date: 12/22/13
* Time: 1:38 PM
*/
namespace Mnd\SrdBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="Mnd\SrdBundle\Repository\MayagRepository")
* @ORM\Table(name="Mayag")
*/
class Mayag {
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string")
* */
protected $name;
/**
* @ORM\OneToMany(targetEntity="CertifyMayag", mappedBy="mayag")
*/
protected $certifies;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
protected $isAvailable;
/**
* @ORM\Column(type="datetime")
*/
protected $startDate;
/**
* @ORM\Column(type="datetime")
*/
protected $endDate;
/**
* @ORM\Column(type="text")
* */
protected $description;
}
3个实体具有自动吸气器设定器。