/** * @return \yii\db\ActiveQuery */ public function getProduct() { return $this->hasOne(Product::className(), ['id' => 'product_id']); }
/** * @return \yii\db\ActiveQuery */ public function getProducts() { return $this->hasMany(Product::className(), ['user_id' => 'id']); }
public function getProduct() { //同样第一个参数指定关联的子表模型类名 return $this->hasOne(Product::className(), ['id' => 'productId']); }