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 8085265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:03:33+00:00 2026-06-05T18:03:33+00:00

I have a question about symfony2. I have a project and I am using

  • 0

I have a question about symfony2.

I have a project and I am using databases with it. I use for the most part Doctrine2 and entity classes. I like the entity class object database stuff, very handy etc.

My question is, is there a way to perform normal SQL in symfony? I always get an exception when I try to use standard SQL. I am having trouble with joins in doctrine2, so i would rather use normal SQL for that.

My join would look like this in SQL:

SELECT DISTINCT Document . * 
FROM Document
INNER JOIN DocumentGruppe ON Document.id = DocumentGruppe.dokId
INNER JOIN UserGruppe ON DocumentGruppe.gruppenId = UserGruppe.gruppenId
WHERE UserGruppe.userId =9

The where clause at the end is just for testing. If I use doctrine with it’s DQL it always says that there is an exception: The Variable DocumentGruppe was not defined before.

Here is my DQL query:

    $test = $em->createQuery(
        'SELECT DISTINCT d
        FROM AcmeDocumentBundle:Document d
        INNER JOIN DocumentGruppe dg ON d.id = dg.dokId
        INNER JOIN UserGruppe ug ON dg.gruppenId = ug.gruppenId
        WHERE ug.userId =9
        '
    );

Does anyone know a workaround or a way to use this doctrine2 stuff to work with joins?

  • 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-06-05T18:03:35+00:00Added an answer on June 5, 2026 at 6:03 pm

    Every JOINED tables must be declared as associations in mapping… How is your entity defined ? Show us your mapping file (Document.php if annotation, or Resources/config/doctrine/document;xml or yml if XMl or YAML).

    Your request will be something like that :

    $test = $em->createQuery(
        'SELECT DISTINCT d
        FROM AcmeDocumentBundle:Document d
        INNER JOIN d.documentGruppen dg
        INNER JOIN d.userGruppen ug
        WHERE ug.userId =9
        '
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question about how the System class works. Lets say there is
I have a question about using session, or maybe TempData to store data while
i have question about why should we use return in get,if dont use what
I'm learning asp.net. I have question about example buttons I can use two types
I have question about removing element from QList. myclass.h: class node2D : public QObject
Today I have question about Eclipse . I use this IDE very long and
I have a question about Symfony2 performance. I have been developing with Symfony2 under
I'm new to Symfony2 and I have maybe a simple question about encoding my
I have a question about local classes in Java (classes that declares in the
I have question about parsing in Html helper : I have sth like: @foreach

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.