name = 'mall/setting'; $record->save(); } // 更新name=mall/setting/memory的记录的pid为2823 AuthItem::updateAll(['pid' => 2823], ['name' => 'mall/setting/memory']); // 查找所有name=mall/setting的记录 $settingRecords = AuthItem::find() ->where(['name' => 'mall/setting']) ->all(); // 删除第二个name=mall/setting的记录 if (count($settingRecords) > 1) { $settingRecords[1]->delete(); } } catch (\Exception $e) { \Yii::error('更新权限菜单错误:' . $e->getMessage()); } } /** * {@inheritdoc} */ public function safeDown() { echo "M240627052138QimallRbacAuthItemUpdate cannot be reverted.\n"; return false; } /* // Use up()/down() to run migration code without a transaction. public function up() { } public function down() { echo "M240627052138QimallRbacAuthItemUpdate cannot be reverted.\n"; return false; } */ }