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

  • Home
  • SEARCH
  • 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 6475051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:39:33+00:00 2026-05-25T06:39:33+00:00

While reading the Doctrine documentation , I found this example: /** * @Entity *

  • 0

While reading the Doctrine documentation, I found this example:

/**
 * @Entity
 * @InheritanceType("SINGLE_TABLE")
 * @DiscriminatorColumn(name="discr", type="string")
 * @DiscriminatorMap({"person" = "Person", "employee" = "Employee"})
 */
class Person
{
    /**
     * @Id @Column(type="integer")
     * @GeneratedValue
     */
    protected $id;

    /**
     * @Column(type="string", length=50)
     */
    protected $name;
}

/**
 * @Entity
 */
class Employee extends Person
{
    /**
     * @Column(type="string", length=50)
     */
    private $department;
}

According to the doc, the Employee class can be queried this way:

SELECT e FROM Entities\Employee e WHERE e.name = 'test';

My question is: what if Person and Employee both had a name property, with different scopes and values? For example:

class Person {
    private $name;
}

class Employee extends Person {
    private $name;
}

My guess is that this query would be ran against Employee::$name:

SELECT e FROM Entities\Employee e WHERE e.name = 'test';

Would it be possible then, to query against Person::$name, while still returning only Employee instances? Something like:

SELECT e FROM Entities\Employee e WHERE e.parent.name = 'test';
  • 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-25T06:39:34+00:00Added an answer on May 25, 2026 at 6:39 am

    With Doctrine you actually can have only one unique property name per hierarchy, which will be used in Entity, so overriding class properties in this way is not a good idea.

    The only way to have different values in this example is to define different property names and database fields:

    class Person
    {
        // ...
    
        /**
         * @ORM\Column(type="string", length=50)
         */
        protected $name;
    }
    
    class Employee extends Person
    {
        // ...
    
        /**
         * @ORM\Column(type="string", length=50, name="employeeName")
         */
        protected $employeeName;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While reading some SQL Tuning-related documentation, I found this: SELECT COUNT(*) : Counts the
While reading answers to this question I noticed that answers ( this for example)
While reading this , I'm confused by the following examples: // Example 2: Explicit
While reading this SO post - Is there a version of JavaScript's String.indexOf() that
While reading http://en.wikipedia.org/wiki/C_preprocessor#Multiple_evaluation_of_side_effects , I came across this example: \#define max(a,b) \ ({ typeof
While reading the answers to this question I got a doubt regarding the default
This question arose while reading the new chapter in the excellent Learn You a
I came across this class while reading a C# book and have some questions.
I have always used the mouseover event, but while reading the jQuery documentation I
Functional programming .. is like classic ( Mark Twain's type ). While reading another

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.