Mysql 为什么Yii2 ActiveRecord会与2个选择一起选择
伙计们。有一些代码:Mysql 为什么Yii2 ActiveRecord会与2个选择一起选择,mysql,activerecord,yii2,Mysql,Activerecord,Yii2,伙计们。有一些代码: City::find()->joinWith('country')->all(); 城市模式: class City extends \yii\db\ActiveRecord { public function getCountry() { return $this->hasOne(Country::className(), ['id' => 'countryId']); } } 但在调试器中,我可以看到
City::find()->joinWith('country')->all();
城市模式:
class City extends \yii\db\ActiveRecord
{
public function getCountry()
{
return $this->hasOne(Country::className(), ['id' => 'countryId']);
}
}
但在调试器中,我可以看到两个查询。我做错了什么?一次尝试执行查询
//second parameter in joinWith will stop to load lazy loading
City::find()->joinWith('country', false)->all();
您正在使用/调用此代码的位置。。在控制器/动作中。。。请显示相关代码..正在运行。actionTest(){City::find()->joinWith('country')->all();返回“”;}@scaisEdgeno-view。。没有渲染?没有别的吗?只有这个密码?是的,只有这个密码,没有更多@斯盖里奇