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
Post a Comment