0
agency_permissions
에서 모든 레코드를 삭제해야합니다. permissions
내부의 module_type이 1
입니다. Yii2에서이를 달성하는 방법은 직접 SQL 삭제 명령을 사용하는 대신 deleteAll()->joinWith()
과 다소 비슷합니다. 이 작업을 수행하는 Yii2 방법을 찾고 있습니다. 아래 표는 다음과 같습니다다른 테이블과 외래 키 관계가있는 전체 레코드를 삭제하는 방법
권한이 비슷한 두 Permissions.php
및 AgencyPermissions.php
모델 이상을 사용한다면, 이런 식으로 뭔가 할 수
+-----+-----------------------------------------------+-------------+
| id | title | module_type |
+-----+-----------------------------------------------+-------------+
| 134 | Case/Container | 1 |
| 141 | Container > Status | 1 |
| 146 | Container > Topic/Sub-topic | 1 |
| 150 | Container > Facility/ Sub-facility | 1 |
| 275 | Allow other cities to compare with this city? | 0 |
| 276 | Activate Outlook Module (choose yes) | 0 |
+-----+-----------------------------------------------+-------------+
agency_permissions
+----+---------+---------------+
| id | govt_id | permission_id |
+----+---------+---------------+
| 1 | 22 | 134 |
| 2 | 22 | 141 |
| 3 | 22 | 146 |
| 4 | 22 | 150 |
| 5 | 22 | 275 |
| 6 | 22 | 276 |
+----+---------+---------------+
은 다음과 같은 것은 없습니다 : -> deleteAll() -> joinWith ('permissions') -> wher e ([ 'permission_id'= $ permissionsIds]); , 권리? – Vipul
아니 ActiveRecord에 대한 설명서에서 본. – marche