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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:50:31+00:00 2026-06-17T06:50:31+00:00

I have entity Patients with a field /** * * @ORM\OneToOne(targetEntity=Surgery\LoginBundle\Entity\User , mappedBy=patient) *

  • 0

I have entity Patients with a field

/**
 *
 * @ORM\OneToOne(targetEntity="Surgery\LoginBundle\Entity\User" , mappedBy="patient")
 * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
 */
 protected $user;

I want to get foreign key from Patiens ,so I created that query

$query = $em->createQuery('SELECT p.user_id FROM SurgeryPatientBundle:Patients p WHERE p.user =5 ');

I get this error

[Semantical Error] line 0, col 9 near 'user_id FROM': Error: Class Surgery\PatientBundle\Entity\Patients has no field or association named user_id '

My question it’s can I get to that field without create JOIN ?

  • 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-17T06:50:33+00:00Added an answer on June 17, 2026 at 6:50 am

    Try this:

    $query = $em->createQuery('SELECT u.id FROM SurgeryPatientBundle:Patients p JOIN p.user u WHERE p.user =5')
    

    or

    $patient = $em->getRepository('SurgeryPatientBundle:Patients')->findOneBy(array('user' => 5));
    $user = $patient->getUser()->getId();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to Entities class Patients { /** * @ORM\OneToOne(targetEntity=ContactAddress, mappedBy=patients) */ protected $contactaddress;
I have a Patient entity and a List entity. A Patient can belong to
I have entity User with one-to-many relationship to UserToUserCategories. When I load user from
More specifically i have 3 entities(doctors, patients, prescripts). The prescripts entity has two foreign
Let's I have entity A and entity B . Entity A have @OneToOne relationship
Technology: Hibernate 3.0 Suppose i have Entity class Company @Entity @Table(name=tbl_companies) public class Company
I'm trying to use composition in hibernate with annotations. I have: @Entity @Table(name =
I am working with Entity Framework ... I have a database table for Patient
I have Entity type class(Serializable, loaded and saved data at runtime) where user specified
I have entity for Doctrine: <?php /** * @Entity * @Table(name=orders) */ class Orders

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.