| |
doctrine-user |
Hello there,
i encountered a problem, when using a left join command in a query.
A few details:
Model A:
Model B:
#code
#here is my query
$l=Doctrine_Query::create()
Now, if i call this the way i do (above), i get the basic results
However, when i add type Doctrine::HYDRATE_ARRAY to the execute
Pretty frustrating - while i am certain that the problem is very basic
Kind regards, James
Basically, what happened is that my joined results were not appearing
in the final results of the query. After carefully testing the
validity of the actual query (by testing the query to mysql directly)
i realized that the problem can not originate from mysql as such.
Consists of an (primary key) 'id' of type string, length 16
and a few other fields, most importantly for this example a field
'code' (string/10)
Has a field 'mandantPath' that is related to model A (field id)
through a hasOne() relation.
$this->hasOne('mandant_db_node as mandant', array
('local'=>'mandantPath','foreign'=>'id'));
->select('*,p.code')
->from('contact_db_customer cc')
->leftJoin('cc.mandant p')
->where($w)
->offset($request['startindex']+0)
->limit($request['rows']+0)
->orderBy($order)
->execute(array());
(fields), but not the joined ones. If i get the SQL query generated by
Doctrine, and use it directly, it works just fine and it returns the
'code' field as it should.
command, i get the correct results, but of course encapsuled.. so that
i have to loop/parse through the result and set the values according
to my demands.
and i just lack the knowledge of a proper solution. Hopefully someone
in here knows what i am dealing with - specifically, what it is that i
am doing wrong.