Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 条令:与属性或位置有许多关系_Php_Database_Orm_Symfony_Doctrine - Fatal编程技术网

Php 条令:与属性或位置有许多关系

Php 条令:与属性或位置有许多关系,php,database,orm,symfony,doctrine,Php,Database,Orm,Symfony,Doctrine,我有这些实体: 第一:ProductCupMain->像产品一样 <?php namespace xxx\Security\Entity; use Doctrine\ORM\Mapping as ORM; /** * xxx\Security\Entity\ProductCupMain * * @ORM\Table(name="product_cup_main") * @ORM\Entity */ class ProductCupMain { /** *

我有这些实体:

第一:ProductCupMain->像产品一样

<?php

namespace xxx\Security\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * xxx\Security\Entity\ProductCupMain
 *
 * @ORM\Table(name="product_cup_main")
 * @ORM\Entity
 */
class ProductCupMain
{
    /**
     * @var integer $id
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

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

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

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

    /**
     * @var ProductCategories
     *
     * @ORM\ManyToMany(targetEntity="ProductCategories", inversedBy="productCupMain")
     * @ORM\JoinTable(name="product_cup_main_has_product_categories",
     *   joinColumns={
     *     @ORM\JoinColumn(name="product_cup_main_id", referencedColumnName="id")
     *   },
     *   inverseJoinColumns={
     *     @ORM\JoinColumn(name="product_categories_id", referencedColumnName="id")
     *   }
     * )
     */
    private $productCategories;
分类实体:

/**
 * @var ProductsInCategory
 * 
 * @OneToMany(targetEntity="ProductCategoryReference", mappedBy="productsCategorie")
 * 
 **/
private $productsInCategory;

//Please show me the getter and setter methods

无法向Dotrine/Doctrine2实体关系添加更多属性。如果您需要保存更多与关系相关的数据(而不是所涉及的实体),那么它就不仅仅是一个简单的关系,不是吗?;-)

您所能做的正是您在图表中所做的——创建3个不同的实体,它们由多个同一/一个同一关系链接。然后您可以自定义该实体并添加所需的信息/职责

编辑

所谓位置,你指的是你设定的位置,对吗?或者你的意思是你想保持它们添加到收藏中的顺序?如果是这样的话,那就有一些悬而未决的问题(和),所以也许我们将来会看到。现在,我认为您必须坚持RelationshipEntity(3个实体)


希望这能有所帮助。

无法向Dotrine/Doctrine2实体关系添加更多属性。如果您需要保存更多与关系相关的数据(而不是所涉及的实体),那么它就不仅仅是一个简单的关系,不是吗?;-)

您所能做的正是您在图表中所做的——创建3个不同的实体,它们由多个同一/一个同一关系链接。然后您可以自定义该实体并添加所需的信息/职责

编辑

所谓位置,你指的是你设定的位置,对吗?或者你的意思是你想保持它们添加到收藏中的顺序?如果是这样的话,那就有一些悬而未决的问题(和),所以也许我们将来会看到。现在,我认为您必须坚持RelationshipEntity(3个实体)


希望这有帮助。

FYI:这不是
category
,而是
category
。我知道编程语言的拐点没有那么聪明,但请……:)非常感谢。如果输入错误出现过,则很难将其删除。。。但我在我的项目中更正了它:-)仅供参考:它不是
category
,而是
category
。我知道编程语言的拐点没有那么聪明,但请……:)非常感谢。如果输入错误出现过,则很难将其删除。。。但我在我的程序中更正了它:-)谢谢,但是如果我用条令自动生成实体,我只得到2个实体,而不是第三个。你说,我必须创建一个新的产品类别,比如:ProductCupMainProductCategories,将它们映射到Manytone-OneToMany?@dennis:mbinette告诉你的是正确的。您必须手动创建您的关系实体并告诉Dority它们之间存在什么关系请查看编辑1您能给我更多信息吗?这就是它!如果你最终拥有很多这样的关系实体,我建议你为实体类使用前缀(这样它们很容易识别……但是“Reference”后缀也很好!)。PS:我还将在Category中定义一个方法来直接获取ProductCupMain对象(如果你不想每次都通过cat->reference->product。比如getProducts(),它将使用产品(按顺序!!!)构建一个集合并直接返回它。没有什么神奇之处,你必须循环引用!;-)非常感谢你!!现在它工作了!我在几分钟内更正了我的代码!谢谢,但是如果我用条令自动生成实体,我只得到2个实体,而不是第三个。你说,我必须创建一个新的产品类别,比如:ProductCupMainProductCategories,将它们映射到Manytone-OneToMany?@dennis:mbinette告诉你的是正确的。您必须手动创建您的关系实体并告诉Dority它们之间存在什么关系请查看编辑1您能给我更多信息吗?这就是它!如果你最终拥有很多这样的关系实体,我建议你为实体类使用前缀(这样它们很容易识别……但是“Reference”后缀也很好!)。PS:我还将在Category中定义一个方法来直接获取ProductCupMain对象(如果你不想每次都通过cat->reference->product。比如getProducts(),它将使用产品(按顺序!!!)构建一个集合并直接返回它。没有什么神奇之处,你必须循环引用!;-)非常感谢你!!现在它工作了!我在几分钟内更正了我的代码!
<?php

namespace xxx\Security\Entity;

use Doctrine\ORM\Mapping as ORM;

    /**
     * xxx\Security\Entity\ProductCategoryReference
     *
     * @ORM\Table(name="product_cup_main_has_product_categories")
     * @ORM\Entity
     */
    class ProductCategoryReference
    {

        /**
         * @ORM\ManyToOne(targetEntity="ProductCupMain", inversedBy="categoriesHavetheProduct") 
         */
        private $prductCupMain;

        /**
         * @ORM\ManyToOne(targetEntity="ProductCategories", inversedBy="productsInCategory")
         */
        private $productsCategorie; 

        /**
         * @ORM\Column(name="postionInCategorie", type="integer", length=164, nullable=false)
         */
        private $postionInCategorie;


        public function getProductCupMain()
        {
            return $this->prductCupMain;
        }

        public function setProductCupMain($prductCupMain)
        {
            $this->prductCupMain = $prductCupMain;
        }

        public function getProductsCategorie()
        {
            return $this->productsCategorie;
        }

        public function setProductsCategorie($productsCategorie)
        {
            $this->productsCategorie = $productsCategorie;
        }

        public function getPostionInCategorie()
        {
            return $this->productsCategorie;
        }

        public function setPostionInCategorie($postionInCategorie)
        {
            $this->postionInCategorie = $postionInCategorie;
        }

    }
/**
 * @var CategoryHavetheProduct
 * 
 * @OneToMany(targetEntity="ProductCategoryReference", mappedBy="productCupMain")
 * 
**/
   private $categoriesHavetheProduct;

   //Please show me the getter and setter methods
/**
 * @var ProductsInCategory
 * 
 * @OneToMany(targetEntity="ProductCategoryReference", mappedBy="productsCategorie")
 * 
 **/
private $productsInCategory;

//Please show me the getter and setter methods