ruba
(Ruba)
1
I want to update a value of a specif id in my table, this is my function that receives the id of the record and do the required update:
public function updateHide($params, $id, $hide) {
$this->incident_id = $id;
$model = Facebook_post_comment_info::find();
$model->where(["incident_id=$this->incident_id"]);
$model->is_hidden = $hide;
$model->save();
}
but it gives me this error:
Setting unknown property: yii\db\ActiveQuery::is_hidden
Davey
(Davey975)
2
I think you forgot the ->one(); part:
public function updateHide($params, $id, $hide) {
$this->incident_id = $id;
$model = Facebook_post_comment_info::find()->where(["incident_id=$this->incident_id"])->one();
$model->is_hidden = $hide;
$model->save();
}
If incident_id is the primary key this is a simpler method:
$model = Facebook_post_comment_info::findOne($this->incident_id);
instead of using this as you have
$model = Facebook_post_comment_info::find();
$model->where(["incident_id=$this->incident_id"]);