Skip to content

Instantly share code, notes, and snippets.

@ovcharenkovv
Created February 20, 2013 13:54
Show Gist options
  • Save ovcharenkovv/4995682 to your computer and use it in GitHub Desktop.
Save ovcharenkovv/4995682 to your computer and use it in GitHub Desktop.
<?php
namespace Moc\GscoreBundle\Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
/**
* @MongoDB\Document
*/
class Athlete
{
/**
* @MongoDB\Id
*/
protected $id;
}
<?php
namespace Moc\GscoreBundle\Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
/**
* @MongoDB\Document
*/
class AthleteScore
{
/**
* @MongoDB\Id
*/
protected $id;
/**
* @MongoDB\ReferenceOne(targetDocument="Athlete")
*/
protected $athlete;
}
$athleteScore = $this->dm->getRepository('GscoreBundle:AthleteScore')->findOneBy(array('athlete.$id' => new \MongoId($athlete)));
$athleteScore = $this->dm->createQueryBuilder('Moc\GscoreBundle\Document\AthleteScore')
->field('athlete')->references($athlete)
->getQuery()->execute();
$athleteScore = $this->dm->createQueryBuilder('Moc\GscoreBundle\Document\AthleteScore')
->field('athlete.$id')->equals(new \MongoId($athlete->getId()))
->getQuery()->execute();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment