I have a quick question. I have a model that I gotta get rid off. I have tried something like the following, but I get an error called Call to a member function delete() on array
:
This is what I have tried so far.
$foundTeams = UserHasTeam::find()->where(['user_has_team.user_iduser' => $model->id])->all();
$foundTeams->delete();
There is static method deleteAll()
for this in ActiveRecord .
UserHasTeam::deleteAll(['user_iduser' => $model->id]);
This will delete all rows from UserHasTeam::tableName() where user_iduser
is $model->id
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.