php - Convert SQL to Doctrine 2 Query Builder or DQL by using NOT IN? -
how convert sql bellow doctrine 2 query builder or dql?
select tags.* tags tags.id not in ( select tag_id totaltags human_resource_tags human_resource_id=1)
tag entity follows:
humanresource entity follows:
basically want select tag entities 1 humanresource entity that humanresource entity not have already.
i struggling here appreciated.
i using doctrine version 2.4.2.
==========================================================================
all hail fuzzytree pointers :)
i have modified , works charm :) tag entities particular humanresource entity not added humanresource entity yet :)
so solution:
$q = $this->createquerybuilder('t') ->where('t.name :name') ->andwhere('not exists ( select h hrapibundle:humanresource h h.id = ' . $humanresource->getid() . 'and h member of t.human_resources )') ->setparameter('name', "%".$query."%") ->getquery();
you can achieve using not exists
, member of
$qb->select("t") ->from('hardcoremore\hrapibundle\entity\tag', 't') ->where('not exists ( select 1 hardcoremore\hrapibundle\entity\humanresource h h.id = 1 , h member of t.human_resources )');
Comments
Post a Comment