DDC-1194: Problem using Instance of feature #1501

Closed
opened 2026-01-22 13:16:15 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Jun 3, 2011).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user hrajchert:

Hi, i get this error message when executing a query with INSTANCE OF.
Notice: Undefined index: \model\PeopleTaskRecommendFriends in /usr/share/php/Doctrine/ORM/Query/SqlWalker.php on line 1626

The query to be executed is this:

                $query = $this->_em->createQuery("SELECT pt
                                          FROM \model\PeopleTask pt
                                          WHERE pt instance of \model\PeopleTaskRecommendFriends
                                          ");

The query actually being executed is this:

SELECT t0*.int_people_task_id AS int_people_task_id0, t0_.int_people_id AS int_people_id1, t0_.dtm_creation AS dtm_creation2, t0_.bit_completed AS bit_completed3, t0_.vch_names AS vch_names4, t0_.int_task_type_id AS int_task_type_id5 FROM tbl_xref_people_task t0_ WHERE (t0_.int_task_type_id = '') AND t0_.int_task_type*id IN ('1', '2')

The first problem is that for some reason its translating the query with a wrong where clause, so of course no data is returned.

Here is the model

------------------------------------------ Base class----------------------------------------
/****
 * @Entity(repositoryClass="repository\PeopleTaskRepository")
 * @InheritanceType("SINGLE_TABLE")
 * @DiscriminatorColumn(name="int*task_type*id", type="integer")
 * @DiscriminatorMap({1 = "PeopleTaskRecommendFriends", 2 = "PeopleTaskAddBadge"})
 * @Table(name="tbl*xref_people*task")
 */
abstract class PeopleTask extends BaseModel {

    /****
     * @Id
     * @GeneratedValue
     ** @Column(type="integer") **/
    protected $int*people_task*id;

    /*** @Column(type="integer") **/
    protected $int*people*id;

    /*** @Column(type="datetime") **/
    protected $dtm_creation;

    /*** @Column(type="bit")**/
    protected $bit_completed;

    /*** @Column(length=255) **/
    protected $vch_names;

}

----------------------------------------------------Children class-----------------------------------------------

/****
 * @Entity(repositoryClass="repository\peopleTask\PeopleTaskRecommendFriendsRepository")
 */
class PeopleTaskRecommendFriends extends PeopleTask {
 /** some methods **/

}
Originally created by @doctrinebot on GitHub (Jun 3, 2011). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user hrajchert: Hi, i get this error message when executing a query with INSTANCE OF. Notice: Undefined index: \model\PeopleTaskRecommendFriends in /usr/share/php/Doctrine/ORM/Query/SqlWalker.php on line 1626 The query to be executed is this: ``` $query = $this->_em->createQuery("SELECT pt FROM \model\PeopleTask pt WHERE pt instance of \model\PeopleTaskRecommendFriends "); ``` The query actually being executed is this: ``` SELECT t0*.int_people_task_id AS int_people_task_id0, t0_.int_people_id AS int_people_id1, t0_.dtm_creation AS dtm_creation2, t0_.bit_completed AS bit_completed3, t0_.vch_names AS vch_names4, t0_.int_task_type_id AS int_task_type_id5 FROM tbl_xref_people_task t0_ WHERE (t0_.int_task_type_id = '') AND t0_.int_task_type*id IN ('1', '2') ``` The first problem is that for some reason its translating the query with a wrong where clause, so of course no data is returned. Here is the model ``` ------------------------------------------ Base class---------------------------------------- /**** * @Entity(repositoryClass="repository\PeopleTaskRepository") * @InheritanceType("SINGLE_TABLE") * @DiscriminatorColumn(name="int*task_type*id", type="integer") * @DiscriminatorMap({1 = "PeopleTaskRecommendFriends", 2 = "PeopleTaskAddBadge"}) * @Table(name="tbl*xref_people*task") */ abstract class PeopleTask extends BaseModel { /**** * @Id * @GeneratedValue ** @Column(type="integer") **/ protected $int*people_task*id; /*** @Column(type="integer") **/ protected $int*people*id; /*** @Column(type="datetime") **/ protected $dtm_creation; /*** @Column(type="bit")**/ protected $bit_completed; /*** @Column(length=255) **/ protected $vch_names; } ----------------------------------------------------Children class----------------------------------------------- /**** * @Entity(repositoryClass="repository\peopleTask\PeopleTaskRecommendFriendsRepository") */ class PeopleTaskRecommendFriends extends PeopleTask { /** some methods **/ } ```
admin added the Bug label 2026-01-22 13:16:15 +01:00
admin closed this issue 2026-01-22 13:16:16 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jun 5, 2011):

Comment created by @beberlei:

A fix for this is probably just ommitting the prefix \ infront of the model in the DQL. Class Names in Strings are ALWAYS fully qualified, therefore the leading slash has to be omitted.

@doctrinebot commented on GitHub (Jun 5, 2011): Comment created by @beberlei: A fix for this is probably just ommitting the prefix \ infront of the model in the DQL. Class Names in Strings are ALWAYS fully qualified, therefore the leading slash has to be omitted.
Author
Owner

@doctrinebot commented on GitHub (Jun 5, 2011):

Comment created by @beberlei:

Improved error handling when in "a INSTANCE OF b" the classes a and b are unrelated.

@doctrinebot commented on GitHub (Jun 5, 2011): Comment created by @beberlei: Improved error handling when in "a INSTANCE OF b" the classes a and b are unrelated.
Author
Owner

@doctrinebot commented on GitHub (Jun 5, 2011):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Jun 5, 2011): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Jun 10, 2011):

Comment created by hrajchert:

Thanks, that did solve my problem.

On a related note, for the original query i had to do this:
$qb->andWhere('pt INSTANCE OF '.$task_type);
instead of this
$qb->andWhere('pt INSTANCE OF :taskType');
$qb->setParameter('taskType', $task_type);

because it complains about the parameter not being a metadata type, and i couldnt find a way to get the metadata type.

@doctrinebot commented on GitHub (Jun 10, 2011): Comment created by hrajchert: Thanks, that did solve my problem. On a related note, for the original query i had to do this: $qb->andWhere('pt INSTANCE OF '.$task_type); instead of this $qb->andWhere('pt INSTANCE OF :taskType'); $qb->setParameter('taskType', $task_type); because it complains about the parameter not being a metadata type, and i couldnt find a way to get the metadata type.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1501