doctrine2 - doctrine dql exception: Illegal offset type in /var/www/Symfony/vendor/doctrine/orm/lib/Doctrine/ORM/Query/SqlWalker.php line 601 -


i want produce dql following mysql query:

select * `folders` `t` `t`.`library` = @mylib , and `t`.`id` not in (    select distinct(`f`.`id`) `folders` `f` join `folders` `ff` on (`f`.`position` concat(`ff`.`position`,  '%')) `ff`.`active` = 1 , `ff`.`library` = @mylib , `f`.`library` = @mylib ) order  `t`.`position` asc 

the query works fine in mysql , returns correct records.
generate dql i've tried both below options:
1.

$query = $em->createquery("select f mybundle:folders t t.library = :libid , t.id not in (          select distinct(f.id) mybundle:folders f join mybundle:folders ff f.position concat(ff.position, '%') , f.library = :libid , ff.library = :libid , ff.active = true       ) order t.position asc")       ->setparameter('libid', $library); $result = $query->getresult(); 

2.

$q1 = $this->createquerybuilder('f')       ->select('distinct(f.id)'); $q1->join('\mybundle\entity\folders', 'ff', 'with', $q1->expr()->like('f.position', $q1->expr()->literal('concat(ff.position, \'%\')')))     ->where('ff.active = true')     ->andwhere("ff.library = '$library'")     ->andwhere("f.library = '$library'");  $q2 = $this->createquerybuilder('t'); $q2->where('t.library = :libid')     ->andwhere($q2->expr()->notin('t.id', $q1->getdql()))     ->setparameter('libid', $library)     ->orderby('t.position', 'asc'); $result = $q2->getquery()->getresult(); 

in perspective seems ok don't know why in both ways produce following exception:

contexterrorexception: warning: illegal offset type in /var/www/symfony/vendor/doctrine/orm/lib/doctrine/orm/query/sqlwalker.php line 601 

any appreciated.

it seems no 1 has answer this. found temporary solution below (i call temporary because i'm changing unique query 2 separate queries , seems issue in core of doctrine).

$qb = $this->createquerybuilder('f')     ->select('distinct(f.id)'); $qb->join('\mybundle\entity\folders', 'ff', 'with', 'f.position concat(ff.position, \'%\')')     ->where('ff.active = true')     ->andwhere("ff.library = :library")     ->andwhere("f.library = :library")     ->setparameter('library', $library);  $included_folders = $qb->getquery()->getarrayresult();  $query = $this->createquerybuilder('f')     ->where('f.active = false')     ->andwhere('f.library = :library')     ->setparameter('library', $library)     ->orderby('f.position', 'asc'); if (!empty($included_folders)) {     if (count($included_folders) > 1)     {         foreach ($included_folders $index => $value)         {             if (is_array($value))              {                 $included_folders[$index] = !empty($value['id']) ? $value['id'] : $value[1];             }         }         $query->andwhere($query->expr()->notin('f.id', $included_folders));     }     else {         $query->andwhere('f.id != :folder ')             ->setparameter('folder', $included_folders[0]);     } } $result = $query->getquery()->getresult(); 

as see instead of getting dql first query , putting inside second dql in notin section lead warning message, execute first query , results put results inside notin if amount of returned values more one, otherwise should in regular !=. solved problem now, see amount of transactions increased
if has better solution or fix warning thankful.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -