symfony - Doctrine - querybuilder - how to make to results from "join" query were not alternately? -


i have table stats , stat_values. these tables in relatioship many 1 (a stat can have lot of stat_value)

i created query via querybuilder:

return $this->getentitymanager()     ->createquerybuilder()     ->select(array('s', 'v'))     ->from("cmailingdefaultbundle:stat", "s")     ->leftjoin("cmailingdefaultbundle:statvalue", "v")     ->where("s.project = :project")     ->andwhere("v.iscurrent = 1")     ->setparameter("project", $project )     ->getquery()     ->getresult(); 

it works good, don't have result in way (i make simpler, because structure of array big):

[0] => stats.field1, stats.field2, ..., stat_values.field1, stat_values, ... [1] => stats.field1, stats.field2, ..., stat_values.field1, stat_values, ... etc... 

but have:

[0] => stats.field1, stats.field2, ... [1] => stat_values.field1, stat_values ... etc... 

it "litle bit" annoying. tried change select arguments "s, v" - results same.

do have ideas how make datas ordered in first way?

could because you're not requesting relation, seperate entity?

instead of:

->from("cmailingdefaultbundle:stat", "s") ->leftjoin("cmailingdefaultbundle:statvalue", "v") 

try:

->from("cmailingdefaultbundle:stat", "s") ->leftjoin("s.statvalue", "v") 

assuming stat entity has relation called statvalue...


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -