$auth = Yii::$app->authManager;
$parent=$auth->createPermission('channel/index');
$parent->description='栏目管理';
$auth->add($parent);
$child=$auth->createPermission('channel/list');
$child->description='查看';
$auth->addChild($parent, $child);
栏目管理这个权限我看数据库是添加进去的,但下面这个子权限就出错。Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails
因为你的子权限在auth_time表里面还不存在,,所有你加不进去,,约束了