doctrine-odm

How can I use regular expressions with Doctrine's Mongodb ODM?

岁酱吖の 提交于 2019-12-03 16:42:16
问题 I'm trying to use regular expressions to query Mongodb using Doctrine's Mongodb ODM on Symfony 2. I know the PHP mongo driver can do it. However, I don't know how to do this with Doctrine. Do I use the same class? How do I reference MongoRegex from within Symfony? 回答1: This came up a while ago on the doctrine-user mailing list. You can use the \MongoRegex class directly in your ODM queries: $documentRepository->findBy(array( 'foo' => new \MongoRegex('/^bar/'), )); Or if using a query builder:

Doctrine Mongodb ODM and DateTime query

江枫思渺然 提交于 2019-12-03 16:36:44
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('PT5M'); $_dateTime->sub($_interval5Min); $query = $this->createQueryBuilder('User') ->field('date_last

Doctrine ODM and schema-less design

女生的网名这么多〃 提交于 2019-12-03 13:40:39
问题 Continuing on from my question about EAV, I'm considering using MongoDB to store product attributes. I will store the catalogue part of this app - Categories, Products and all their related information - with MongoDB (or another document database). My question is, when using an ODM, each entity has a schema, which essentially disregards the schema-less advantage of using a NoSQL database, does it not? If this is correct, why would anyone use an ODM? EDIT: I found a related question, could I

How can I use regular expressions with Doctrine's Mongodb ODM?

这一生的挚爱 提交于 2019-12-03 05:47:25
I'm trying to use regular expressions to query Mongodb using Doctrine's Mongodb ODM on Symfony 2. I know the PHP mongo driver can do it . However, I don't know how to do this with Doctrine. Do I use the same class? How do I reference MongoRegex from within Symfony? This came up a while ago on the doctrine-user mailing list. You can use the \MongoRegex class directly in your ODM queries: $documentRepository->findBy(array( 'foo' => new \MongoRegex('/^bar/'), )); Or if using a query builder: $queryBuilder->field('foo')->equals(new \MongoRegex('/^bar/')); Keep in mind that front-anchored, case

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

送分小仙女□ 提交于 2019-12-03 01:02:06
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 try to $dm->refresh($audit) I get the same thing. Is there anyway for me to go back to the database for

Query data not show in view in zf2? [duplicate]

心已入冬 提交于 2019-12-02 20:15:50
问题 This question already has an answer here : how to show data from document to index.phtml in zf2? (1 answer) How to get query result in zf2? [duplicate] Closed 5 years ago . I make an index action in which i used doctrine query to select data from calendar table and i want to show data using index.phtml but my data not show only blank page shown,how i show data from controller to view? here is my code: public function indexAction() { $dm = $this->getServiceLocator()->get('doctrine

MongoException: zero-length keys are not allowed, did you use $ with double quotes?

人盡茶涼 提交于 2019-11-30 15:28:08
问题 I'm using symfony2 and mongodb, until today, everything is OK, but I create a new document, and suddenly, appears this error : "MongoException: zero-length keys are not allowed, did you use $ with double quotes?" $dm = $this->get('doctrine.odm.mongodb.document_manager'); $_repo = $dm->getRepository('CantaoCustomerBundle:CustomerTags'); $_repo->findOneByCustomer($customer); The $customer it's OK, the repository is empty, and my document class is like this : /** * @MongoDB\ID **/ private $id; /

MongoException: zero-length keys are not allowed, did you use $ with double quotes?

假如想象 提交于 2019-11-30 14:54:58
I'm using symfony2 and mongodb, until today, everything is OK, but I create a new document, and suddenly, appears this error : "MongoException: zero-length keys are not allowed, did you use $ with double quotes?" $dm = $this->get('doctrine.odm.mongodb.document_manager'); $_repo = $dm->getRepository('CantaoCustomerBundle:CustomerTags'); $_repo->findOneByCustomer($customer); The $customer it's OK, the repository is empty, and my document class is like this : /** * @MongoDB\ID **/ private $id; /** * @MongoDB\ReferenceOne(targetDocument="Tapronto\Mats\ProductBundle\Document\Tag", cascade={"persist

How to integrate ZF2 with Doctrine Mongo ODM? [closed]

╄→гoц情女王★ 提交于 2019-11-30 07:39:50
I am trying to integrate zf2 beta3 with doctrine mongo odm (https://github.com/doctrine/DoctrineMongoODMModule) but no sucess. How can I install and configure it? superdweebie I'm doing just the same thing. Something like this should work: Download the module, and place in your vendor folder. Add the module in application.config.php Copy module.doctrine_mongodb.config.php.dist to /config/autoload Edit that config file with your own settings Change the name of that config file to module.doctrine_mongodb.local.config.php Create a 'setDocumentManager' method in your controller like this:

How to integrate ZF2 with Doctrine Mongo ODM? [closed]

我怕爱的太早我们不能终老 提交于 2019-11-29 09:52:32
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . I am trying to integrate zf2 beta3 with doctrine mongo odm (https://github.com/doctrine/DoctrineMongoODMModule) but no sucess. How can I install and configure it? 回答1: I'm doing just the same thing. Something