doctrine2 - Check If Record Has References -
i wonder if there way find out if record has references.
i have following entity:
class item extends entity { /** * @id @generatedvalue * @column(name="id") */ protected $id; /** * @onetomany(targetentity="citation", mappedby="citation") */ protected $citedin; /** * @column(name="stamped", type="boolean") */ protected $stamped; /** ... rest of code ... */ }
and want perform following check:
$qb ->select(" count(i.id), when (i.stamped = true) 'stamped' when (i.citedin not null) 'cited' else 'just started' end current_status ") ->from(entity\item::class, 'i') ->groupby('current_status');
note tried use i.citedin not null
, didn't work. use instead?
since onetomany
relationship think need use is not empty
instead of is not null
. doctrine create empty arraycollection each entity, technically it's not null, because it's empty array.
update
if doesn't work, try not instance of yourapp\model\citation
.
Comments
Post a Comment