Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6668437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:02:31+00:00 2026-05-26T03:02:31+00:00

I am working on a webapp that has three entities: User, Project, and Todo.

  • 0

I am working on a webapp that has three entities: User, Project, and Todo.

Every Todo has a many-to-one relationship with Projects.
Todos also have a many-to-many relationship to Users.

What I am trying to do is retrieve projects that contain a todo that has been assigned to a given user.

My code is as follows. $id has been set to the user_id I want to retrieve projects for

$em = $this->getDoctrine()->getEntityManager();
$projects = $em->createQuery("SELECT p FROM projects p INNER JOIN p.todos t WITH t.assigned_to = :id")
    ->setParameter('id', $id)
    ->getResult();

Whenever I run this query I get the following error:

[Semantical Error] line 0, col 79 near ‘assigned_to =’: Error: Invalid
PathExpression. StateFieldPathExpression or
SingleValuedAssociationField expected.

Any thoughts on what I am doing wrong? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:02:31+00:00Added an answer on May 26, 2026 at 3:02 am

    Updated:

    As the assigned_to relation is a many to many relation pointed out in the comments there is no actual field assigned_to for the comparision.

    You have to join the association:

    SELECT p 
    FROM projects p 
    INNER JOIN p.todos t 
    INNER JOIN t.assigned_to a
    WHERE a.id = :id
    

    I am using the WHERE condition as thats what I am accustomed to, as I learned from you WITH is also supported and might work, too 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a PHP-based webapp that has an existing MySQL database where all
It has come down from high places that a webapp I've been working on
Our design has one jvm that is a jboss/webapp (read/write) that is used to
I have to design an webapp that has the capability of working offline. So
I'm currently working on a fairly large project that has been migrated from Ant
I am working on a web app project that has been in development for
I have inherited a working VB.NET 2.0 web app that has several User Controls
I'm working on a webapp in jquery that, on older machines or machines without
Years back I built a simple mail form that has been working like a
I'm working on a web app that currently has a table-based layout. Ideally I'd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.