I'm trying to create a todo list kind of app. At the moment I am just trying to output all the tasks based on the user instanced user id. I'm having some trouble writing the query using $user->getId()
as the parameter for user_id.
Here's what I have:
public function indexAction()
{
$user = $this->getUser();
//var_dump($user);
$em = $this->getDoctrine()->getManager();
$query = $em->createQuery(
'SELECT p
FROM TaskBundle:Task p
WHERE p.user_id = :user_id'
)->setParameter('user_id', $user->getId());
$tasks = $query->getResult();
return $this->render('Default/index.html.twig', array(
'tasks' => $tasks,
));
}
I've tried QueryBuilder and DQL and I am getting the same error.
An exception occurred while executing 'SELECT t0_.id AS id0, t0_.name AS name1, t0_.done AS done2, t0_.created AS created3, t0_.updated AS updated4, t0_.user_id_id AS user_id_id5 FROM tasks t0_ WHERE t0_.user_id_id = ?' with params [1]:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0_.user_id_id' in 'field list'