{"action":"opened","issue":{"url":"https://api.github.com/repos/doctrine/DoctrineMongoDBBundle/issues/395","repository_url":"https://api.github.com/repos/doctrine/DoctrineMongoDBBundle","labels_url":"https://api.github.com/repos/doctrine/DoctrineMongoDBBundle/issues/395/labels{/name}","comments_url":"https://api.github.com/repos/doctrine/DoctrineMongoDBBundle/issues/395/comments","events_url":"https://api.github.com/repos/doctrine/DoctrineMongoDBBundle/issues/395/events","html_url":"https://github.com/doctrine/DoctrineMongoDBBundle/issues/395","id":197840957,"number":395,"title":"Second setCollection not working","user":{"login":"hiniesta","id":2779910,"avatar_url":"https://avatars.githubusercontent.com/u/2779910?v=3","gravatar_id":"","url":"https://api.github.com/users/hiniesta","html_url":"https://github.com/hiniesta","followers_url":"https://api.github.com/users/hiniesta/followers","following_url":"https://api.github.com/users/hiniesta/following{/other_user}","gists_url":"https://api.github.com/users/hiniesta/gists{/gist_id}","starred_url":"https://api.github.com/users/hiniesta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hiniesta/subscriptions","organizations_url":"https://api.github.com/users/hiniesta/orgs","repos_url":"https://api.github.com/users/hiniesta/repos","events_url":"https://api.github.com/users/hiniesta/events{/privacy}","received_events_url":"https://api.github.com/users/hiniesta/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-28T11:47:46Z","updated_at":"2016-12-28T11:47:46Z","closed_at":null,"body":"I have Document set in collections by year. When I tried to set the collection two times, the second one doesn't work. Here is my script:\r\n`\r\n/* fist select */\r\n$dm = $this->get('doctrine_mongodb')->getManager();\r\n  $dm->getClassMetadata('\\MyBundle\\Document\\Myobject')->setCollection('Myobject_2016');\r\n\r\n$resumen = $dm\r\n            ->createQueryBuilder('MyBundle:Myobject')\r\n             ->select()\r\n            ->getQuery()\r\n            ->execute()\r\n            ->toArray();\r\n\r\n/* Data from collectio Myobject_2016 -> OK*/\r\n\r\n/* second select */\r\n  $dm->getClassMetadata('\\MyBundle\\Document\\Myobject')->setCollection('Myobject_2017');\r\n$resumen2 = $dm\r\n            ->createQueryBuilder('MyBundle:Myobject')\r\n             ->select()\r\n            ->getQuery()\r\n            ->execute()\r\n            ->toArray();\r\n/* Error, $resumen2 query is executed in Myobjecto2016 collection*/\r\n`\r\n\r\n\r\nHere is the log of the query\r\n`\r\ndb.Myobject_2016.find();\r\ndb.Myobject_2016.find();`\r\n\r\nAny help how to change the second time the document collection?"}}
{"actor":{"display_login":"hiniesta"}}