我在yii2模型中有以下关系
private void txtPassword_Leave(object sender, EventArgs e)
{
if(txtPassword.Text == "")
{
txtPassword.PasswordChar = '\0'; // Note this line!
txtPassword.Text = "Enter a password...";
txtPassword.ForeColor = Color.Gray;
}
}
如何从关系" public function getStreamsFormations()
{
return $this->hasMany(StreamsFormations::className(), ['stream_id' => 'id']);
}
public function getFormations()
{
return $this->hasMany(Formations::className(), ['id' => 'formation_id'])->via('streamsFormations');
}
"创建完整的mysql查询?
我需要它在其他地方使用它......
我用过......
getFormations()
但它从查询中跳过了via关系表。
答案 0 :(得分:0)
关系没有条件!他们只是加入2桌到主题!你必须把你的条件放在find()查询中! 如果您需要更多信息,请告诉我。