Details
Description
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 */ }
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.