草庐IT

doctrine

全部标签

php - Symfony 中的注释机制——它是如何工作的?

我已经开始学习Symfony(4.1),我有一个关于注释的问题。据我所知,注释只是php方面的注释,它们不是语言本身的一部分。然而,它们在Symfony中是相当强大的东西。我想知道这一切是如何运作的。是否有一个代码预处理器可以动态解析源文件并创建新的php实体?但如果是这样,它会如何影响应用程序的性能?为什么我应该为某些注释使用特殊的命名空间?简单地说,我想知道Symfony中的注释是如何工作的,这个功能的机制。 最佳答案 是的,注释确实不是语言本身的一部分。但它们也不是Symfony框架的一部分。注释通常由doctrine/ann

php - 从现有数据库生成实体时出现无效参数异常

我正在将Symfony2项目从Propel转换为Doctrine,并希望将现有数据库转换为Doctrine实体。为此,我正在关注tutorialontheSymfonywebsite,但是当我运行以下命令时:php应用程序/控制台doctrine:mapping:convertxml./src/Acme/BlogBu​​ndle/Resources/config/doctrine/metadata/orm--from-database--force我立即收到以下错误:[InvalidArumentException]DoctrineORMManagernamed""doesnotexi

php - doctrine2 查询生成器中的子查询出错

我有一个带有子查询的查询:$query=$this->getEntityManager()->createQueryBuilder();$subquery=$query;$subquery->select('f.following')->from('ApiBundle:Follow','f')->where('f.follower=:follower_id')->setParameter('follower_id',$id);$query->select('c')->from('ApiBundle:Chef','c')->where('c.id:id')->setParameter('

php - Symfony2,Doctrine2 在关联 sth#category 上找到类型为 Doctrine\Common\Collections\ArrayCollection 的实体,但期待 sth

现在我在表单中提交帖子数据时遇到问题(我的表单如下所示:Task:Category:DueDate:)提交表单后,我会收到此错误:FoundentityoftypeDoctrine\Common\Collections\ArrayCollectiononassociationAcme\TaskBundle\Entity\Task#category,butexpectingAcme\TaskBundle\Entity\Category我的来源:任务对象Task.phpcategory=new\Doctrine\Common\Collections\ArrayCollection();}/

php - Doctrine executeUpdate 数组参数

我如何使用数组更新Doctrine,这样我就不会每次都做for循环(我只想对数据库进行1次调用)$myarray=[1,2,3];$sql="UPDATE`mytable`SETis_processing=:is_processing,end_time=NOW()WHEREid=:id";$result=$this->connection->executeUpdate($sql,array('is_processing'=>false,'id'=>$myarray//Thisisunknownnumberamountofarray));我想要实现的是:它应该用字段is_processi

php - 类 Entities\USER_User 中的注释 "@Doctrine\ORM\Mapping\Entity"不存在,或者无法自动加载

我想在我的ZendFramework-Application中结合使用Doctrine2和“l3pp4rd/DoctrineExtensions”。但我只收到以下错误消息:Theannotation"@Doctrine\ORM\Mapping\Entity"inclassEntities\USER_Userdoesnotexist,orcouldnotbeauto-loaded.应用程序\bootstrap.phpprotectedfunction_initDoctrine(){require_once('Doctrine/Common/ClassLoader.php');$autol

php - Symfony Form如何自动设置 child 的 parent

在我的formType上我添加了另一个子表单//ParentFormType$builder->add('children','collection',array('type'=>newChildFormType(),'prototype'=>true,'allow_delete'=>true,'allow_add'=>true,));//ChildFormType$builder->add('age','text',array('required'=>true));当我尝试保存表单以foreach子项并设置父项时,有没有办法避免这种foreach。$em=$this->get('do

php - doctrine2 : in a one-to-many bidirectional relationship, 如何从反面保存?

我有下面的一对多双向关系。在使用symfony2任务生成crud操作后,当我尝试在新建/编辑类别表单中保存与类别关联的产品时,产品未保存...namespacePrueba\FrontendBundle\Entity;useGedmo\Mapping\AnnotationasGedmo;useDoctrine\ORM\MappingasORM;useDoctrine\Common\Collections\ArrayCollection;/***@ORM\Entity*@ORM\Table(name="category")*/classCategory{/***@varinteger$i

php - Doctrine 2 : Generated entities from database don't have namespaces

我正在通过\Doctrine\ORM\Tools\DisconnectedClassMetadataFactory()类从数据库创建实体。这非常有效!除了namespace生成。没有生成namespace。我将我的实体存储在App/Model/Entities中。有谁知道如何让生成器为实体添加命名空间?这是我用来生成实体的代码:getConfiguration()->setMetadataDriverImpl(new\Doctrine\ORM\Mapping\Driver\DatabaseDriver($em->getConnection()->getSchemaManager()))

php - Symfony 2.1 Sonata Admin Bundle OneToMany

假设我有两个实体:1。产品/***@ORM\Table()*@ORM\Entity*/classProduct{/**@ORM\Column(name="name",type="string",length=255)*/private$name;/***@ORM\OneToMany(targetEntity="Catalog",mappedBy="product")*/public$catalogs;publicfunction__construct(){$this->catalogs=new\Doctrine\Common\Collections\ArrayCollection();