<?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();
$section = UserToSection::findAll(['user_id' => \Yii::$app->user->getId()]);
foreach($section as $one){
$one->delete();
}
UserToSection::deleteAll([
'user_id' => \Yii::$app->user->getId()
]);