I have little problem, I want to print id of user, but I have an error: "Undefined offest: 0". Here is my code:
$rsm = new ResultSetMapping(); $em = $this->getDoctrine()->getManager(); $user= $this->get('security.context')->getToken()->getUser(); $query = $em->createNativeQuery('SELECT id FROM fos_user WHERE username_canonical = ?', $rsm); $query->setParameter(1, $user); $users = $query->getResult(); echo $users['id'];
Somebody have idea what is wrong?