草庐IT

doctrine-odm

全部标签

Mongodb 用 groupby 之类的东西限制结果数

我有一个具有多个层次结构的MongoDB集合,例如,我将使用一个包含国家/地区的集合,其中包含城市,每个文档都是针对特定城市的,并且包含国家/地区和城市的人口值(country_pop和city_popin示例)这非常简单,我实际上有6个层次结构和大量数据。[{"country":"France","city":"Paris","country_pop":63000000,"city_pop":2200000,"year":2015},{"country":"France","city":"Marseille","country_pop":63000000,"city_pop":850

mongodb - Doctrine EventListener onFlush 获取旧 Document

我可以在Doctrine2的onFlusheventListerner中访问更新的文档。我想要完整的旧文档以旧状态将其存储在其他地方。publicfunctiononFlush(OnFlushEventArgs$eventArgs){$dm=$eventArgs->getDocumentManager();$uow=$dm->getUnitOfWork();foreach($uow->getScheduledDocumentUpdates()as$document){//$documentisupdateddocument//$changeSetcontainsonlynewandol

php - 什么是 PHP Doctrine MongoDB ODM 中的鉴别器字段冲突?

报错是什么意思Discriminatorfield"x"in"y"conflictswithamappedfield's"name"attribute.被抛出?更具体地说,我指的是这种情况:if($this->discriminatorField!==null&&$this->discriminatorField===$mapping['name']){throwMappingException::discriminatorFieldConflict($this->name,$this->discriminatorField);}ReferalCode 最佳

mongodb - Doctrine/MongoDB : Use key-value pairs instead numeric array

我正在将DoctrineODM与MongoDB结合使用。我有一个这样的“产品模型”:namespaceCms\Model;/**@Document(collection="products")*/classProduct{/**@Id*/private$id;/**@String*/private$title;/**@String*/private$description;/**@Date*/private$createdAt;/**@EmbedMany(targetDocument="Cms\Model\ProductParam")*/private$params;/**@Embed

php - Doctrine ODM/MongoDB : in AND in queries

我正在将DoctrineODM与mongoDB结合使用。我正在尝试执行如下查询:$queryBuilder->field('array_field')->in('even_value_1','event_value_2');$queryBuilder->field('array_field')->in('odd_value_1','odd_value_2');这个想法是选择所有在他们的文档中array_field(event_value_1ORevent_value_2)AND(odd_value_1ORodd_value_2)使用我正在使用的语法,我得到的文档有event_value

zend-framework - ZendFramework,带有 mongoDB 的 Doctrine 2 ODM - Hydrator 错误

我将ZendFramework与Doctrine2和mongoDB结合使用。到目前为止一切顺利。现在我正在重写我的自定义验证类,以检查用户名是否已存在于数据库中。(此代码适用于ORM和MySQL,但现在不适用于ODM和mongoDB)。所以我的自定义验证类如下所示:"'%value%'istaken.Pleasechooseanotherusername.");publicfunctionisValid($value){//settingvaluefortheform$this->_setValue($value);//getthedocumentmanagerandrepositor

php - 使用 Doctrine MongoDB ODM 为收集设置 TTL

从MongoDB2.2开始,可以将“ExpireDatafromCollectionsUsingaTTL”实现为一种特殊的索引类型。最新版本的DoctrineORM支持这个IndexOption.不幸的是,我无法找到如何使用原则注释/配置文件正确设置此索引。这就是我尝试做的方式,我希望有人能帮助我正确设置它:然后当我执行phpapp/consoledoctrine:mongodb:schema:update时(在symfony2.3.x中)索引已生成,但生成的索引看起来不正确。这是我在数据库中执行db.system.indexes.find();时得到的结果:{"v":1,"key":

php - 如何在mongodb querybuilder中 "group by"字段 "count"?

我想用他们拥有的产品对城市进行分类。我有两个文档:Product和city。该产品具有其ID和对城市文档的引用:Product(id)CityP1------------AtlantaP2------------NewYorkP3------------MichiganP4------------Atlanta....我想要作为查询的结果[Atlant=>23,NewYork=>35,Michigan=>23,etc..]但我无法得到结果。我的实际代码是publicfunctioncountBestUsers(){return$this->createQueryBuilder()->s

mongodb - Doctrine 2 MongoDB 获取对象的子记录

我正在使用doctrine/mongodb-odm-bundle我遇到了一个问题:我无法从文档中获取引用的行(或者我只是不知道该怎么做......)我有2个这样的一对多引用文档:首先/***@MongoDB\Document(collection="categories")*/classCategory{/***@varinteger$id**@MongoDB\Id(strategy="auto")*/private$id;/***@varstring$name**@MongoDB\String*@Assert\NotBlank()*@Assert\MinLength(3)*/priv

mongodb - Doctrine MongoDB ODM 身份验证,可能吗?

有没有办法在DoctrineMongoDBODM中使用MongoDB身份验证?相当于shell中的db.auth(username,password) 最佳答案 最稳健的方法是在连接URI中指定您的用户名和密码(例如mongodb://username:password@localhost),因为如果连接断开,需要重新连接。您也可以使用MongoDB::authenticate()如果您需要在单个连接中针对各种数据库进行身份验证,但如果连接断开,则必须手动重新进行身份验证。查看connectiondocumentation更多示例。