Skip to content

confused about viaTable()  #8

@xchl

Description

@xchl

What steps will reproduce the problem?

for example I have three tables. order , item , order_item

Class Order extends ActiveRecord
{
    public function getItems()
    {
        return $this->hasMany(Item::className(), ['id' => 'item_id'])
            ->viaTable('order_item', ['order_id' => 'id']);
    }
}
Order::findOne(1)

The querys
1.select * from order where id=1;
2.select * from order_item where order_id = 1;(empty result)
3.select * from item where 0=1; (why have this? );
I looked the source code
image

What is the expected result?

What do you get instead?

Additional info

Q A
Yii version 2.0.5
PHP version 7.1.9
Operating system

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions