我收到此错误:
Notice: Undefined index: userTrack in C:\Program Files (x86)\Zend\Apache2\htdocs
\app\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php on line 110
文件.php:
/**
* @ORM\OneToOne(targetEntity="JJ\MainBundle\Entity\UserTrack", mappedBy="file", fetch="EAGER")
* @JMS\Expose
*/
protected $user_track;
用户跟踪.php:
/**
* @ORM\OneToOne(targetEntity="JJ\MainBundle\Entity\File", inversedBy="user_track", fetch="EAGER")
*/
protected $file;
我可以很好地生成实体。我可以很好地更新我的架构。是什么赋予了?
编辑:
public function findRandomByUser(User $user)
{
$pointer = rand(0, $user->getFiles()->count() - 1);
$query = $this->getEntityManager()->createQuery("
SELECT f
FROM MainBundle:File f
WHERE f.user = :user
")
->setMaxResults(1)
->setFirstResult($pointer)
->setParameters(array(
'user' => $user->getId()
));
return $query->getSingleResult();
}