doctrine-odm

Weird Doctrine ODM exception when using references together with inheritance

痴心易碎 提交于 2019-12-22 11:23:23
问题 I've got three classes. The File-Class has a reference to Foobar and Game inherits from Foobar. There are some other Classes which also inherit from Foobar but i left them out as they aren't relevant here. I also left out some unrelevant fields and their getters and setters. The plan is that every Game has two images, the mainImage and the secondaryImage. I've put those fields into a seperate class from which Game inherits because i need them for a few other classes too. My problem is that if

JMS Serializer Deserialize with abstract parent class

蓝咒 提交于 2019-12-21 09:31:27
问题 I have an abstract parent (mapped super-)class which has several children with different properties which I'd like to deserialize. I'm storing the data using MongoDB and Doctrine ODM, so I also have a discriminator field which tells doctrine which subclass is used (and also have a custom "type" property ontop which is used elsewhere to determine which class is currently processed). When deserializing my model, I get an exception telling me that its impossible to create an instance of an

Doctrine MongoDB result caching

孤街醉人 提交于 2019-12-21 05:07:32
问题 How would one go about caching Doctrine MongoDB results? Looking at the code for Configuration it doesn't appear to have a built in result cache like standard Doctrine, only a query cache. I have thought of creating my own cache layer in the app but the returned objects are quite heavy as they contain lots of Doctrine logic not needed by the view. How can I pair down the objects so they are effectively just data containers? 回答1: Doctrine MongoDB ODM does not support query caching, so this is

Doctrine MongoDB result caching

非 Y 不嫁゛ 提交于 2019-12-21 05:07:04
问题 How would one go about caching Doctrine MongoDB results? Looking at the code for Configuration it doesn't appear to have a built in result cache like standard Doctrine, only a query cache. I have thought of creating my own cache layer in the app but the returned objects are quite heavy as they contain lots of Doctrine logic not needed by the view. How can I pair down the objects so they are effectively just data containers? 回答1: Doctrine MongoDB ODM does not support query caching, so this is

How do I force doctrine to reload the data from the database?

霸气de小男生 提交于 2019-12-20 11:48:08
问题 I'm using doctrine/mongodb 1.0.0-BETA1 in a symfony2.1 install. So i'm trying to force my repository to call data from my database instead of using the object it has cached. $audit = $dm->getRepository("WGenSimschoolsBundle:Audit")->findOneById("xxxx"); .... do something somewhere to change the object .... At this point if I call $audit = $dm->getRepository("WGenSimschoolsBundle:Audit")->findOneById("xxxx"); The audit data hasn't changed. It still has the object it originally fetched. If I

How to configure Monolog to store logs into MongoDB with Symfony2 and Doctrine

萝らか妹 提交于 2019-12-19 10:23:30
问题 Would it be possible to get a full example of how is it possible to configure Monolog to store its logs into MongoDB using Symfony 2.6 and Doctrine 2? 回答1: Full configuration /app/parameters.yml mongodb_server: "mongodb://localhost:27017" mongodb_username: "vagrant" mongodb_password: "password" mongodb_database: "testdb" /app/config.yml # Doctrine2 MongoDB Bundle # http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html doctrine_mongodb: default_database: %mongodb_database%

mongodb odm how to get highest value of a column?

非 Y 不嫁゛ 提交于 2019-12-14 04:01:03
问题 I wrote this, but i think it is wrong way. $lastPointContent = $dm->createQueryBuilder('PointContent') ->sort('pageNumber','desc')->limit(1)->getQuery()->getSingleResult(); I can't find any other way to making it look better. 回答1: I don't know exactly about the syntax for doctrine-odm or PHP regarding Mongo but it seems to me that what you must do is: Find that specific collection Sort it with -1 the field you want Limit it to 1 Check if there if there is a 'next' element in the query and, if

How do I get a list of MongoDB documents that are referenced inside another collection

我怕爱的太早我们不能终老 提交于 2019-12-13 00:35:06
问题 I am trying to find a way to get a list of MongoDB documents that are referenced in a subdocument in another collection. I have a collection with user documents. In another collection I keep a list of businesses. Every business has a subdocument containing a list of references to users. The User collection: /* user-1 */ { "_id" : ObjectId("54e5e78680c7e191218b49b0"), "username" : "jachim@example.com", "password" "$2y$13$21p6hx3sd200cko4o0w04u46jNv3tNl3qpVWVbnAyzZpDxsSVDDLS" } /* user-2 */ { "

How to properly Autoload Doctrine ODM annotations?

假如想象 提交于 2019-12-12 21:09:09
问题 Trying to run the command line tool w/ odm:schema:create and I'm getting errors like: "[Semantical Error] The annotation "@Document" in class Company_Model_Auth was never imported. Did you maybe forget to add a "use" statement for this annotation?" and "[Semantical Error] The annotation "@EmbeddedDocument" in class Company_Model_Auth was never imported. Did you maybe forget to add a "use" statement for this annotation?" as well as others, basically for every annotation. When I add "use

Doctrine Mongodb ODM and DateTime query

时间秒杀一切 提交于 2019-12-12 08:14:02
问题 I could use some help on this problem. I'm creating an application using Symfony2 + mongodb + doctrine. I just want to use Doctrine ODM to query all the users who have been logged in the last 5 minutes. I have a User collection with a date field called date_last_login. So I try to use the querybuilder like that: <?php // Creating a DateTime object and susbtract 5 min from now // local time is 15:40:05, timezone: 'Europe/Paris' $_dateTime = new \DateTime(); $_interval5Min = new \DateInterval(