php - Problems with Doctrine Subqueries and Aliases -


previously today, asked/answered following question: https://stackoverflow.com/a/43069362/4521733

now tried create query using doctrine query builder:

$qb->select('sp')     ->addselect(         '(select count(spa.id) appbundle:projectattribute spa spa.project = sp.id , spa.attribute = pa.attribute , spa.attributevalue = pa.attributevalue) attributesimilarity'     )     ->addselect(         '(attributesimilarity * 1) similarity'     )     ->from('appbundle:project', 'p')     ->leftjoin('appbundle:projectattribute', 'pa', 'with', 'p = pa.project')     ->leftjoin('appbundle:project', 'sp', 'with', 'p != sp')     ->where('p = :project')     ->setparameter(':project', $project)     ->groupby('sp.id')     ->orderby('similarity', 'desc')     ->getquery()     ->getresult(); 

unfortunately doesn't work:

sqlstate[42s22]: column not found: 1054 unknown column 'attributesimilarity' in 'field list' 

the problem doctrine renames subquerys "as attributesimilarity" , on "as sclr_35", doesn't rename field names within last addselect.

i tried write subqueries within single addselect. doesn't work @ all.

what did wrong?


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -