草庐IT

php - Symfony2 : Duplicate definition of column 'id' on entity in a field or discriminator column mapping

我在Symfony2中使用实体继承时遇到问题。这是我的两个类(class):useDoctrine\ORM\MappingasORM;/***@Orm\MappedSuperclass*/classObject{/***@varinteger**@ORM\Column(name="id",type="integer")*@ORM\Id*@ORM\GeneratedValue(strategy="AUTO")*/private$id;}/***@Orm\MappedSuperclass*/classBookextendsObject{}当我运行phpapp/consoledoctrine

php - XML 解析错误 : undefined entity - special characters

为什么XML在某些特殊字符上显示错误,而有些却没问题?例如,下面会产生错误,Löic但这没关系,&我是通过php转换特殊字符的-htmlentities('Löic',ENT_QUOTES)顺便说一下。我该如何解决这个问题?谢谢。编辑:我发现如果我使用诸如Lóic之类的数字字符,它可以正常工作现在我必须找到如何使用php将特殊字符转换为数字字符! 最佳答案 XML规范中定义了五个实体——&、、>、'和”有lotsofentitiesdefinedintheHTMLDTD.您不能在通用XML中使用来自HTML的内容。

php - 学说/Symfony : Entity with non-mapped property

如何将不应映射到数据库的属性添加到Entity类?我需要该属性作为临时值。因此,不应从数据库中获取属性或将其保存到数据库中。它也不应该是一个sql计算值,我只需要在php代码中设置(和获取)它。 最佳答案 编写没有注释的属性不应作为实体用户的示例链接到您的数据库。classUser{/***@ORM\Id*@ORM\Column(type="integer")*@ORM\GeneratedValue(strategy="AUTO")*/protected$id;/***@ORM\Column(type="array")*/prote

php - 使用 Symfony2 的表单 - 具有一些不可变构造函数参数和 OneToMany 关联的 Doctrine Entity

IhaveaOneToManyassociationbetweenaServerentityandCliententitiesinthedatabase.Oneservercanhavemanyclients.Iwanttomakeaformwheretheusercanchooseaserverfromadropdown,fillinsomedetailsforanewclient,andsubmitit.目标要创建一个表单,用户可以在其中将数据输入到Client的字段中,请从下拉列表中选择一个Server,然后单击提交并获得此数据(以及association)通过Doctrine持

php - 在 Doctrine 中,如何为 Entity 实现额外的模型功能

假设我有一个Doctrine(版本2)的实体,如下所示:现在,我想管理User与Group的关系,但是有一些条件,比如:返回NULL(或\AppBundle\Entity\Group的某种骨架/模板,具有未从数据库加载的固定值)如果Groupusers.group_id的>不存在,即使它被设置为一个值(数据库中没有设置键限制来防止这种行为),所以需要某种验证/检查延迟加载Group,当调用$user->getGroup()我一直在阅读谷歌,但我对如何正确(按照Doctrine/Symfony方式)实现这一目标感到困惑。我可以将ManyToOne添加到实体的类关系中,如下所示:/***@

php - Symfony 中的 Doctrine 2 : Listening for events from a particular Entity

我有一个Doctrine实体(新闻),我监听事件prePersist。为此,我使用方法prePersist的事件监听器。我的services.yml看起来像这样:listener.entity.news:class:A\BBundle\Listeners\Entity\NewsListenertags:-{name:doctrine.event_listener,event:prePersist}这很好,一切正常。但是文档指出,当persist()被调用时,会产生一个prePersist事件。然后,正如我的配置所述,NewsListener将捕获它并执行一些代码。在捕获事件的方法中,我

php - Doctrine Entity增加值(下载计数器)

我想增加我的Doctrine实体的值(value)。目前我是这样做的。$file->setDownloadCounter($file->getDownloadCounter()+1);$em=$this->getDoctrine()->getManager();$em->persist($fileVersion);$em->flush();有没有办法在Doctrine中执行这样的事情:UPDATEfileSETdownloadCounter=downloadCounter+1WHEREid=1编辑:上面的Doctrine示例中的问题是加载和刷新之间是其他人可以下载文件的时间,因此计数器

php - 扩展 Doctrine Entity 以添加业务逻辑

我正在尝试实践良好的设计并扩展Doctrine实体。我的扩展类,基本上是模型,将具有额外的业务逻辑+对实体基本数据的访问。我正在使用Doctrine2.2.1&ZendFramework1.11.4&php5.3.8当我使用DQL时,学说成功返回模型实体。当我使用Doctrinenativefind()函数时,它什么都不返回:(。帮助...它是这样滚动的:Bootstrap.php:$classLoader=new\Doctrine\Common\ClassLoader('Entities',APPLICATION_PATH.'/doctrine');$classLoader->reg

php - symfony3 : create form for entity that has a column with many to one relationship

我有一个“任务”表,它引用了一个“Estados”表,该表具有从列Tasks.taskestado到Estados.estado的外键。这是任务的相关XML映射:......对于Estados:...鉴于此,我正在尝试执行一个操作(novaAction())来创建任务。这是Controller代码:publicfunctionnovaAction(Request$request){$task=newTasks();$em=$this->getDoctrine()->getManager();dump($task);#$task->setTaskEstado(newEstados());

php - 学说 2 : Saving Entity in Complex Relationship

我的学说实体中有以下关系:最喜欢的食谱/***@ManyToOne(targetEntity="User",inversedBy="favoriteRecipes")*/private$user;/***@ManyToOne(targetEntity="Recipe",inversedBy="favoriteRecipes")*/private$recipe;食谱/***@OneToMany(targetEntity="FavoriteRecipe",mappedBy="user")*/private$favoriteRecipes;用户/***@OneToMany(targetEnt