草庐IT

doctrine2

全部标签

mongodb - 如何使用 mongodb 从 doctrine ODM 中的引用文档数组中删除文档

我有一个php对象映射到具有结构的mongodb文档(称为Node)useDoctrine\ODM\MongoDB\Mapping\AnnotationsasMongoDB;classNode{/***@MongoDB\Id*/protected$id;/***@MongoDB\String*/protected$domain;/***@MongoDB\ReferenceMany(targetDocument="NodeItem",cascade=*{"persist"},simple="true")*/protected$items=array();//getterandsetter

php - 无法使用 Composer 安装 doctrine/mongodb-odm

尝试通过Composer安装doctrine/mongodb-odm我得到了这个:LoadingcomposerrepositorieswithpackageinformationUpdatingdependencies(includingrequire-dev)Yourrequirementscouldnotberesolvedtoaninstallablesetofpackages.Problem1-doctrine/mongodb1.0.x-devrequiresext-mongo>=1.2.12,therequestedPHPextensionmongoismissingfro

mongodb - 当 child 是拥有方时,Doctrine Mongo 级联删除 child

我有一个父/子OneToMany引用:/***@ODM\Document*/classParent{//.../***@var\Doctrine\Common\Collections\ArrayCollection*@ODM\ReferenceMany(targetDocument="Child",mappedBy="parent")*/protected$children;//...}/***@ODM\Document*/classChild{//.../***@varParent*@ODM\ReferenceOne(targetDocument="Parent",inversedB

mongodb - Doctrine ODM 节省大量资金

这可能是一个愚蠢的问题,但我正在努力在mongoDB文档中保存一个大数字。基本上,我想保存一个可以大于maxint值的数字。因此,我将我的文档字段声明为@Field(type="float")。现在的问题是保存数字会导致错误。我也试过简单地使用@Integer但数字减少到2147483647(这是32位系统的最大int值)。所以我尝试了最后一个解决方案,将我的号码保存在一个字符串中。这工作正常(至少它在数据库中看起来是正确的),但返回文档并执行echo$number返回2147483647。有人解决这个问题吗?我做错了什么? 最佳答案

mongodb - Doctrine MongoDB 查询嵌入文档

我有带有嵌入关键字文档(UserEmbedMany关键字)的顶级文档User。好吧,我不知道如何通过关键字的id从具体用户获取关键字对象我花了很多时间试图解决这个问题,但它对我来说仍然是个问题。所以我帮助这里的人会帮助我。非常感谢。 最佳答案 您只能从mongodb加载父文档。但是有$slice仅使用有限数量的嵌入文档即可加载父文档的运算符。在本地mongodb语言上你可以这样做:db.users.find({_id:"UserId","Keywords._id","keywordId"},{Keywords:{$slice:1}}

mongodb - 如何使用 Doctrine ODM for MongoDB 设置我自己的 MongoId?

useDoctrine\ODM\MongoDB\Mapping\AnnotationsasODM;/***@ODM\Document()*/classMy_Doctrine_Model{/**@ODM\id*/protected$id;publicfunctiongetId(){return$this->id;}publicfunctionsetId($value){$this->id=$value;return$this;}}代码$myModel=newMy_Doctrine_Model();$myModel->setId(newMongoId());//Idismysetid$dm

mongodb - 坚持和冲洗 - Doctrine 和 MongoDB

flush()有多快?我正在使用persist()将几千项添加到集合中,然后清空集合然后刷新它。$dm=$this->get('doctrine.odm.mongodb.document_manager');while(stuff)){$item=newItem();$item->setItem("itemstuff");$dm->persist($item);}$qb=$dm->createQueryBuilder('Bundle:Item')->remove();$query=$qb->getQuery();$query->execute();$dm->flush();我想知道集合

mongodb - Doctrine MongoDB delete 仅引用 onRemove

我在ChartPage和BaseChart之间有一对多关系:1个ChartPage包含1个BaseChart并且1个BaseChart包含多个ChartPages图表在我的应用程序的不同包中进行管理,因此可以单独删除它们。我喜欢的是,当图表被删除时,Doctrine会自动删除ChartPage.Chart引用,但没有别的(不删除ChartPage)。另一种方法应该让一切保持原样:当我删除带有引用BaseChart的ChartPage时-什么都不会发生(不删除BaseChart)我尝试了其中一个的所有组合:cascade="{detach,merge,refresh,remove,per

php - 找不到类 'MongoId'(Zend Framework with MongoDB Doctrine)

我目前正在尝试将MongoDB与ZendFramework中的Doctrine集成。我做了很多教程(在StackOverflow或其他任何地方),但没有任何效果。我一步步跟着教程:http://www.bigwisu.com/2012/10/03/zend-framework-2-doctrine-odm我得到了一个我不明白的错误。Fatalerror:Class'MongoId'notfoundin/home/prooxi/www/zframework/vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Types/IdType.

mongodb - 如何使用我自己的数据作为 Doctrine MongoDB 映射文档的 ID 而不是自动生成的对象 ID?

MongoDBdocumentationonObjectIDs建议在特定情况下使用自定义键:Ifyourdocumenthasanaturalprimarykeythatisimmutablewerecommendyouusethatin_idinsteadoftheautomaticallygeneratedids.我怎样才能定义一个简单的模型对象来完成这个任务? 最佳答案 word;}publicfunctionsetWord($word){$this->word=$word;}}只需确保在调用persist()之前设置了$wo