How to get join data if using columns?

I have two tables, ProductGroup and ProductGroupTranslation which are joined together.

In ProductGroup I have id and in translation table I have title.

Now I want to get all ProductGroups: $categories = ProductGroup::find(array( "productgroupid IS NULL", "order" => "id DESC" ) );

This works and I can acces translation via $categories->productgrouptranslation->getTitle();

But how do I access joined table if I fetch only columns out: $categories = ProductGroup::find(array( "columns" => "id", "productgroupid IS NULL", "order" => "id DESC" ) );

edited May '14

Here some false explanation was given... ;-)


Renski you understood me wrong. Both examples return correct data, just in second one where i specify columns, I cannot access joined data anymore.


Hmm.. you're right, I was mistaken, adding something in array without key automatically assigns it an index, starting at 0..

edited May '14

I looked at it a little, and have actually dealt with this in the past...

For some reason, when providing columns, Phalcon will give you a resultset containing Rows that contain simply an array of key => value pairs instead of Rows containing actual Models. Only in the latter case you can fetch related records.

I am not sure if this is documented / further commented on somewhere, has been a while I dealt with this myself...

Edit: when searching I found some similar topics (providing answers):


Zaay, I have a similar problem but I'm also having trouble joining my two tables. Would you mind posting your models code?