jjzjj

PersistentCollection

全部标签

php - 类 Doctrine\ORM\PersistentCollection 的对象无法转换为字符串

我用Symfony2制作了一个Web应用程序,其中一个User有一个数组关联ManytoMany与实体Mission。用户可以通过表单上传实体$product,表单传递的数据之一是与用户相关的任务。当我尝试上传数据时,出现错误:ContextErrorException:CatchableFatalError:ObjectofclassDoctrine\ORM\PersistentCollectioncouldnotbeconvertedtostringinC:\BitNami\wampstack-5.4.23-0\frameworks\symfony\vendor\doctrine\

php - Symfony 3/Doctrine - 获取实体更改集中关联的更改

所以我已经知道我可以在preUpdate生命周期事件中获取对特定实体的更改:/***Capturespre-updateevents.*@paramPreUpdateEventArgs$args*/publicfunctionpreUpdate(PreUpdateEventArgs$args){$entity=$args->getEntity();if($entityinstanceofParentEntity){$changes=$args->getEntityChangeSet();}}但是,有没有办法同时获取任何关联实体的更改?例如,假设ParentEntity具有如下关系设置:

php - 在 Doctrine\ORM\PersistentCollection 中定义自定义方法

我正在获取具有多对多关系的数据,我想定义一个自定义方法。是否有可能(以及如何)使用类似的东西:$hotel=$entityManager->getRepository('Hotels')->findOneById(1);$types=$hotel->getTypes();//$typesisinstanceof**Doctrine\ORM\PersistentCollection**$types->myCustomFunction();//dosomething 最佳答案 它似乎还没有实现。请参阅此Doctrine的JIRA问题:h

php - Doctrine manyToMany 返回 PersistentCollection 而不是 ArrayCollection

我正在使用Symfony3.1和Doctrine2.5。我一如既往地设置了一个多对多关系:manyToMany:placeServices:targetEntity:Acme\MyBundle\Entity\PlaceServicejoinTable:name:place_place_servicejoinColumns:place_id:referencedColumnName:idinverseJoinColumns:place_service_id:referencedColumnName:id并向我的实体添加方法protected$placeServices;...public

php - Doctrine manyToMany 返回 PersistentCollection 而不是 ArrayCollection

我正在使用Symfony3.1和Doctrine2.5。我一如既往地设置了一个多对多关系:manyToMany:placeServices:targetEntity:Acme\MyBundle\Entity\PlaceServicejoinTable:name:place_place_servicejoinColumns:place_id:referencedColumnName:idinverseJoinColumns:place_service_id:referencedColumnName:id并向我的实体添加方法protected$placeServices;...public

php - Symfony 2/学说 2 : get changes to PersistentCollection

我正在构建一个应用程序,用户可以在其中编辑一些数据,然后会看到一个屏幕,用户可以在其中确认(并评论)他的编辑。在确认表单中,我显示了对实体所做的更改。这适用于“正常”字段。下面是一些用于检查单个字段的代码://create$form//bind$formif($form->isValid(){$data=$form->getData();//example,getchangesofa"normal"fieldif($data['color']!=$entity->getColor()){//dosomethingwithchanges}}但我不能对关系做同样的事情(例如ManyToMa

php - Symfony2 - 在 Twig 中获取一个实体而不是 PersistentCollection

我正在使用symfony2,但无法在twig中获取相关实体。所以我有我的主要实体,我们称它为Post,它具有OneToMany关系:/***@ORM\OneToMany(targetEntity="Comment",mappedBy="Post",cascade={"persist","remove"})*/private$comments;我用我的Controller将它传递给twig,我可以访问每个属性,但是当我尝试访问具有“Comment”之类关系的属性时,我得到一个“Doctrine\ORM\PersistentCollection)"里面有很多私有(private)属性(pr

php - 不能对我的一个实体使用 Doctrine PersistentCollection,另一个我可以

我有一对关联。它们是多对多的,我使用显式创建的实体来加入它们,这样我就可以获得有关关系的元数据。虽然它们是相同的,但一个有效,另一个无效。更糟糕的是,上周,它们都起作用了,从那以后我就再也没有碰过它们。在MuSQLWorkbench中,我可以选择正确的数据。当我将数据提取到一个数组中时,生活是美好的。当我尝试另一个时,我得到:CalltoamemberfunctionsetValue()onanon-object当我尝试count()、访问它($blah[0])或迭代它(foreach)。当我执行时:echoget_class($inData)."";echoget_class($in