Задать вопрос
Justique
@Justique

Почему Yii2 ActiveRecord Model не удаляет?

Не понимаю почему ошибка Call to a member function delete()
776a1a5413d5418bb16d1ec797466dff.png
7b6858f7877544c3b78ad04645ba165e.png

Вот модель
<?php
namespace common\models;

use Yii;
use yii\base\NotSupportedException;
use yii\db\ActiveRecord;

/**
 * UserToSection model
 *
 * @property integer $id
 * @property integer $user_id
 * @property integer $section_id
 */
class UserToSection extends ActiveRecord
{
	


    /**
     * @inheritdoc
     */
    public static function findIdentity($id)
    {
        return static::findOne(['id' => $id]);
    }
	
}


Обращение к модели
$section = UserToSection::findAll([
				'user_id' => \Yii::$app->user->getId()
			]);
			print_R($section);
			$section->delete();
  • Вопрос задан
  • 892 просмотра
Подписаться 1 Оценить 4 комментария
Решение пользователя Justique К ответам на вопрос (2)
Justique
@Justique Автор вопроса
Сам задал, сам и отвечаю
$section = UserToSection::deleteAll([
				'user_id' => \Yii::$app->user->getId()
			]);
Ответ написан
Комментировать