Question

I have an entity with an 'object' type column. I want to be able to retreive the entity by a property (say id) of that object. For example, the query would look something like this:

$em->createQuery('SELECT e FROM Entity_Class e SOME_MAGIC e.object o WHERE o.id = ?1');

The question is, is there *SOME_MAGIC* in dql?

Was it helpful?

Solution

This is not possible an object type column is serialized into a CLOB field using serialize(). There is no way to query subproperties of it.

OTHER TIPS

A possible solution but not the optimal one is to use a like expr:

 $qb->add($qb->expr()->like("e.column", $qb->expr()->literal("%text_to_search%")));

Because in doctrine 2 in some RDBMS, the object are persist in longtext type and not CLOB or BLOB.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top