Transitive left join results in repetitive records

Its 2.0.9.

There is an "accommodation". The "accommodation" has many "accommodatiobase". And "accommodationbase" has one "city"

So accommodation:

$this->hasMany('id', 'AccommodationBase', 'accommodation_id', array('alias' => 'AccommodationBase'));


$this->belongsTo('city_id', 'City', 'id', array('alias' => 'City'));

and here is my builder:

$queryBuilder = (new \Phalcon\Mvc\Model\Query\Builder())->from('Accommodation')->where(' = 1');

the result [$queryBuilder->getQuery()->execute()] returns with tons of "accomodation", repetitve records. It should return one (check the where condition)

so in other words, joins:

A -> b

A -> c

workds but

A -> B -> C

results in many A (as much as C)

edited Dec '15

Post the resultant SQL with getQuery()->getSql()["sql"]. You can build the PHQL yourself and if you are having issues with keys then you can disable implicit joining based on the defined relationships with the enable_implicit_joins option. Set it with the static method Model::setup or as an option in the query.