草庐IT

doctrine-collection

全部标签

php - 自动生成 Doctrine 的 get set 方法

我正在使用Doctrine我必须制作很多模型,如果我不必手动完成所有操作就好了。我这样设置和属性:/***@varstring$name**@Column(name="Name",type="string",length=100,nullable=false)*/private$name;get&set方法由信息组成,这些信息完全包含在属性声明中。那么有没有人知道有什么工具可以从属性声明中生成如下所示的getset方法。/***Setname**@paramstring$name*@returnUser*/publicfunctionsetName($name){$this->name

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 - 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 - Symfony2 Doctrine 从类别中获取随机产品

我有以下数据库方案:table'products'idcategory_id当然还有类别表,只有一个id。数据看起来像这样:Products--------------------|id|category_id|--------------------|0|1||1|1||2|1||3|2||4|2||5|1|--------------------我想选择一个类别(例如类别1),因此我在我的产品存储库类中选择该类别的所有行:return$this->createQueryBuilder('u')->andWhere('u.category=:category')->setMaxRes

php - Doctrine2 (Symfony2) 生成的约束中奇怪的随机名称

出于某种原因,当我使用生成迁移时phpapp/consoledoctrine:migrations:diff我得到了一些奇怪的约束和索引名称,例如FK_FFE561C6BE3BD8D4和IDX_FFE561C6BE3BD8D4:$this->addSql("ALTERTABLEagent_taskADDagentConfig_idINTUNSIGNEDDEFAULTNULL,DROPagent_id");$this->addSql("ALTERTABLEagent_taskADDCONSTRAINTFK_FFE561C6BE3BD8D4FOREIGNKEY(agentConfig_id

php - 在 Laravel 5 Collection 中,如何返回对象数组而不是数组数组?

我正在使用Laravel5和Blade模板。在一个View中,我想遍历一个模型对象数组,而不是一个数组数组。如果我确实想遍历数组数组,我会执行以下操作,这会按预期工作:$models=Foo::where('id','>',5)->get();returnview('home.index',['models'=>$models->toArray()]);但是我想要一个具有可访问属性的对象数组。如果我要跑:$models=Foo::where('id','>',5)->get();returnview('home.index',['models'=>$models->all()]);va