why the _related filed alway null when I use activerecord

for the following code in my catagory model


// declare relation

public function getCatagoryDescription()

{

    return $this->hasOne(OcCategoryDescription::className(), ['category_id' => 'category_id']);

}


public function getCategories($parent_id = 0)

{

    $a = '${parent_id}';

    $result = $this->find()->joinWith('catagoryDescription', true);

    $result = $result->where('parent_id = ' . $parent_id . ' and status = 1');

    $result = $result->orderBy('oc_category.sort_order, LCASE(oc_category_description.name)');


    [color="#FF0000"][b]//$result = $result->asArray();[/b][/color]


    $result = $result->all();




    return $result;

}



if i do not use the asArray method, then I can’t get the related object

6053

QQ20141102141710.gif

if I add the code $result = $result->asArray();, then I can get the catagory description data.

6054

QQ20141102141758.gif

I haven’t find a good case to describe this, are there someone know the answer?

I appreciate it if it could be solved today…

more details: https://github.com/yiisoft/yii2/issues/5879


:rolleyes:

(I still have little problem on English, but I am getting better)

::) ::) ::) ::) ::) ::) ::) ::)

still waiting online!!!////////////////////////

more details: https://github.com/yiisoft/yii2/issues/5879