DQL Code:
$dql = "SELECT a, FIELD(a.id, ".$implodedIds.") as HIDDEN field "
. "FROM \activity\models\Entities\Activity a "
. "WHERE a.id IN (".$implodedIds.") "
. "ORDER BY field ASC ";
$em = \Zend_Registry::get('em');
$doctrineConfig = $em->getConfiguration();
$doctrineConfig->addCustomStringFunction('FIELD', 'DoctrineExtensions\Query\Mysql\Field');
$query = $em->createQuery($dql);
$docResults = $query->getResult();
General Gist of Entity Structure: (Single Table Inheritance)
Activity
Opinion extends Activity
Comment extends Activity
Counter extends Activity
This dql code is returning Activity entities, however I want it to automatically discriminate the entities it returns into Opinions, Comments, and Counters. Doctrine does this without any issues in other instances, but not here for some reason. (I.E. in other cases where I make a query asking for Activity, it gives me an array of Opinions, Comments and Counters)
Can anybody tell me why this time, it’s not discriminating them automatically?
You ask the “activities”, and he returns to them! According to your schema options are “activities” … If you ask your options, you are more specific, and not get the other children of “activity” … So to differentiate, use “instanceOf”!