Cakephp 3 ORM使用patchEntity保存多个_joinData 供应商计划表 供应商稳定 供应商方案输入类型稳定 供应商模式稳定 供应商方案供应商表
我需要允许管理员能够更新SupplierSchemaItemsSupplierTable中的数据。但是,当我尝试使用下面的Cakephp 3 ORM使用patchEntity保存多个_joinData 供应商计划表 供应商稳定 供应商方案输入类型稳定 供应商模式稳定 供应商方案供应商表,cakephp,orm,Cakephp,Orm,我需要允许管理员能够更新SupplierSchemaItemsSupplierTable中的数据。但是,当我尝试使用下面的 $SuppliersTable->patchEntity($supplier, $this->request->data(), [ 'associated' => [ 'SupplierSchemas.SupplierSchemaItems.Suppliers', ]
$SuppliersTable->patchEntity($supplier, $this->request->data(), [
'associated' => [
'SupplierSchemas.SupplierSchemaItems.Suppliers',
]
]);
它适用于供应商\方案\项目\ id和供应商\ id都不同的行。但是,对于可能有多个项目的select(标识文件),它会失败,即只更新第一条记录并删除第二条记录
以下是请求数据的数据转储:
[
(int) 0 => [
'id' => '1',
'supplier_schema_items' => [
(int) 2 => [
'id' => '3',
'suppliers' => [
(int) 0 => [
'id' => '1',
'_joinData' => [
'id' => '3',
'value' => 'Current Signed Passport - Edit Test'
]
],
(int) 1 => [
'id' => '1',
'_joinData' => [
'id' => '4',
'value' => 'Driving Licesnce - Edit Test 2'
]
]
]
]
]
]
]
如果您添加要保存的数据的转储,可能会有所帮助。@ndm我现在已添加请求数据数组。如果您添加要保存的数据的转储,可能会有所帮助。@ndm我现在已添加请求数据数组
$this->hasMany('SupplierSchemaItems');
+----+----------+
| id | title |
+----+----------+
| 1 | Text |
| 2 | Textarea |
| 3 | Select |
+----+----------+
$this->belongsTo('SupplierSchemas');
$this->belongsToMany('Suppliers', [
'through' => 'SupplierSchemaItemsSuppliers',
]);
+----+--------------------------+--------------------+--------------------------------+
| id | title | supplier_schema_id | supplier_schemas_input_type_id |
+----+--------------------------+--------------------+--------------------------------+
| 1 | Partners | 1 | 1 |
| 2 | Bio | 1 | 2 |
| 3 | Identification Documents | 1 | 3 |
+----+--------------------------+--------------------+--------------------------------+
$this->belongsTo('SupplierSchemasInputTypes');
$this->belongsTo('SupplierSchemaItems');
$this->belongsTo('Suppliers');
+----+-------------------------+-------------+-------------------------+
| id | supplier_schema_item_id | supplier_id | value |
+----+-------------------------+-------------+-------------------------+
| 1 | 1 | 1 | 4 |
| 2 | 2 | 1 | Supplier Bio Text |
| 3 | 3 | 1 | Current Signed Passport |
| 4 | 3 | 1 | Driving Licence |
+----+-------------------------+-------------+-------------------------+
$SuppliersTable->patchEntity($supplier, $this->request->data(), [
'associated' => [
'SupplierSchemas.SupplierSchemaItems.Suppliers',
]
]);
[
(int) 0 => [
'id' => '1',
'supplier_schema_items' => [
(int) 2 => [
'id' => '3',
'suppliers' => [
(int) 0 => [
'id' => '1',
'_joinData' => [
'id' => '3',
'value' => 'Current Signed Passport - Edit Test'
]
],
(int) 1 => [
'id' => '1',
'_joinData' => [
'id' => '4',
'value' => 'Driving Licesnce - Edit Test 2'
]
]
]
]
]
]
]