如何访问可排序输入 Yii2 中项目数组中的键
How to access the keys in array of items in Sortable-Input Yii2
我很难想出如何解决这个问题。
我想知道如何访问和使用项目数组中的键,以便在 batchInsert 中使用?
考虑到下一个场景:我有一个像这样的 tableA
id | tableB_id | tableC_id
其中id_tableA是自增,tableB_id和tableC_id都是FK。
我需要在 tableA 中插入来自 tableB 的多个 id,其中 select 来自连接的 Sortable,以及来自 tableC 的相同 id,来自下拉列表 selected,结果如下:
id | tableB_id | tableC_id
--------------------------
1 | 2 | 4
2 | 3 | 4
3 | 5 | 4
. | . | 4
n | x | 4
当我 select 只有 1 项并提交表单时没有问题,但是当我 select 两个或更多时我无法提交,因为显然 tableB_id 只能接受整数。
如何将您的 Dosis ID 更改为字符串,然后 explode(',', $dosisId)
获取 ID 数组?
我很难想出如何解决这个问题。 我想知道如何访问和使用项目数组中的键,以便在 batchInsert 中使用?
考虑到下一个场景:我有一个像这样的 tableA
id | tableB_id | tableC_id
其中id_tableA是自增,tableB_id和tableC_id都是FK。 我需要在 tableA 中插入来自 tableB 的多个 id,其中 select 来自连接的 Sortable,以及来自 tableC 的相同 id,来自下拉列表 selected,结果如下:
id | tableB_id | tableC_id
--------------------------
1 | 2 | 4
2 | 3 | 4
3 | 5 | 4
. | . | 4
n | x | 4
当我 select 只有 1 项并提交表单时没有问题,但是当我 select 两个或更多时我无法提交,因为显然 tableB_id 只能接受整数。
如何将您的 Dosis ID 更改为字符串,然后 explode(',', $dosisId)
获取 ID 数组?