doq70020 2015-02-23 15:35
浏览 34

symfony 2如何在不同的包中创建或映射实体

I have project which have different bundles. I want to create or divide entities in different bundle how can I create this. I am new in symfony please help me . I created but I can not do mapping correctly . a table which have primary key can't use in another bundle.

Here is my Entity

namespace DomainBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * WebsiteDomainConfigTest
 *
 * @ORM\Table(name="website_domain_config_test", indexes={@ORM\Index(name="fk_website_domain_config_test_1_idx", columns={"vendor_id"}), @ORM\Index(name="fk_website_domain_config_test_2_idx", columns={"country_id"})})
 * @ORM\Entity
 */
class WebsiteDomainConfigTest 
{
    /**
     * @var string
     *
     * @ORM\Column(name="domain", type="string", length=255, nullable=true)
     */
    private $domain;

    /**
     * @var string
     *
     * @ORM\Column(name="vendor_code", type="string", length=15, nullable=true)
     */
    private $vendorCode;

    /**
     * @var string
     *
     * @ORM\Column(name="domain_path", type="string", length=255, nullable=true)
     */
    private $domainPath;

    /**
     * @var string
     *
     * @ORM\Column(name="assets_path", type="string", length=45, nullable=true)
     */
    private $assetsPath;

    /**
     * @var string
     *
     * @ORM\Column(name="language", type="string", length=3, nullable=true)
     */
    private $language;

    /**
     * @var string
     *
     * @ORM\Column(name="affiliate", type="string", length=25, nullable=true)
     */
    private $affiliate;

    /**
     * @var string
     *
     * @ORM\Column(name="affiliate_logo", type="string", length=255, nullable=true)
     */
    private $affiliateLogo;

    /**
     * @var string
     *
     * @ORM\Column(name="affiliate_address", type="string", length=255, nullable=true)
     */
    private $affiliateAddress;

    /**
     * @var integer
     *
     * @ORM\Column(name="status", type="integer", nullable=true)
     */
    private $status;

    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var \MobileSplash\SplashRequestBundle\Entity\Countries
     *
     * @ORM\ManyToOne(targetEntity="MobileSplash\SplashRequestBundle\Entity\Countries")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="country_id", referencedColumnName="id")
     * })
     */
    private $country;

    /**
     * @var \MobileSplash\SplashRequestBundle\Entity\Vendors
     *
     * @ORM\ManyToOne(targetEntity="MobileSplash\SplashRequestBundle\Entity\Vendors")
     * @ORM\JoinColumns({
     * @ORM\JoinColumn(name="vendor_id", referencedColumnName="id")
     * })
     */
    private $vendor;



    /**
     * Set domain
     *
     * @param string $domain
     * @return WebsiteDomainConfigTest
     */
    public function setDomain($domain)
    {
        $this->domain = $domain;

        return $this;
    }

    /**
     * Get domain
     *
     * @return string 
     */
    public function getDomain()
    {
        return $this->domain;
    }

    /**
     * Set vendorCode
     *
     * @param string $vendorCode
     * @return WebsiteDomainConfigTest
     */
    public function setVendorCode($vendorCode)
    {
        $this->vendorCode = $vendorCode;

        return $this;
    }

    /**
     * Get vendorCode
     *
     * @return string 
     */
    public function getVendorCode()
    {
        return $this->vendorCode;
    }

    /**
     * Set domainPath
     *
     * @param string $domainPath
     * @return WebsiteDomainConfigTest
     */
    public function setDomainPath($domainPath)
    {
        $this->domainPath = $domainPath;

        return $this;
    }

    /**
     * Get domainPath
     *
     * @return string 
     */
    public function getDomainPath()
    {
        return $this->domainPath;
    }

    /**
     * Set assetsPath
     *
     * @param string $assetsPath
     * @return WebsiteDomainConfigTest
     */
    public function setAssetsPath($assetsPath)
    {
        $this->assetsPath = $assetsPath;

        return $this;
    }

    /**
     * Get assetsPath
     *
     * @return string 
     */
    public function getAssetsPath()
    {
        return $this->assetsPath;
    }

    /**
     * Set language
     *
     * @param string $language
     * @return WebsiteDomainConfigTest
     */
    public function setLanguage($language)
    {
        $this->language = $language;

        return $this;
    }

    /**
     * Get language
     *
     * @return string 
     */
    public function getLanguage()
    {
        return $this->language;
    }

    /**
     * Set affiliate
     *
     * @param string $affiliate
     * @return WebsiteDomainConfigTest
     */
    public function setAffiliate($affiliate)
    {
        $this->affiliate = $affiliate;

        return $this;
    }

    /**
     * Get affiliate
     *
     * @return string 
     */
    public function getAffiliate()
    {
        return $this->affiliate;
    }

    /**
     * Set affiliateLogo
     *
     * @param string $affiliateLogo
     * @return WebsiteDomainConfigTest
     */
    public function setAffiliateLogo($affiliateLogo)
    {
        $this->affiliateLogo = $affiliateLogo;

        return $this;
    }

    /**
     * Get affiliateLogo
     *
     * @return string 
     */
    public function getAffiliateLogo()
    {
        return $this->affiliateLogo;
    }

    /**
     * Set affiliateAddress
     *
     * @param string $affiliateAddress
     * @return WebsiteDomainConfigTest
     */
    public function setAffiliateAddress($affiliateAddress)
    {
        $this->affiliateAddress = $affiliateAddress;

        return $this;
    }

    /**
     * Get affiliateAddress
     *
     * @return string 
     */
    public function getAffiliateAddress()
    {
        return $this->affiliateAddress;
    }

    /**
     * Set status
     *
     * @param integer $status
     * @return WebsiteDomainConfigTest
     */
    public function setStatus($status)
    {
        $this->status = $status;

        return $this;
    }

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

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

    /**
     * Set country
     *
     * @param \MobileSplash\SplashRequestBundle\Entity\Countries $country
     * @return WebsiteDomainConfigTest
     */
    public function setCountry(\MobileSplash\SplashRequestBundle\Entity\Countries $country = null)
    {
        $this->country = $country;

        return $this;
    }

    /**
     * Get country
     *
     * @return \MobileSplash\SplashRequestBundle\Entity\Countries 
     */
    public function getCountry()
    {
        return $this->country;
    }

    /**
     * Set vendor
     *
     * @param \MobileSplash\SplashRequestBundle\Entity\Vendors $vendor
     * @return WebsiteDomainConfigTest
     */
    public function setVendor(\MobileSplash\SplashRequestBundle\Entity\Vendors $vendor = null)
    {
        $this->vendor = $vendor;

        return $this;
    }

    /**
     * Get vendor
     *
     * @return \MobileSplash\SplashRequestBundle\Entity\Vendors 
     */
    public function getVendor()
    {
        return $this->vendor;
    }
}
  • 写回答

1条回答 默认 最新

  • douji1058 2015-02-23 16:19
    关注

    in your annotation use namespace like this:

    targetEntity="\Mj\FooBundle\Entity\Foo"
    
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?