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:

tag entity

humanresource entity follows:

humanresource entity

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

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -