関数
ComboGroup::reorderComboGroups( int $comboSetId, int[] $groupIds )
パラメータ パラメータ
- $comboSetId
(数値) (必須)
- $groupIds
(int[]) (必須)
true
if anything was reordered, false
otherwiseファイル: src/API/ComboGroup.php
public static function reorderComboGroups($comboSetId, $groupIds) { global $wpdb; $comboSetId = (int)$comboSetId; $groupIds = !empty($groupIds) ? (array)$groupIds : []; $updated = false; $wpdb->query('START TRANSACTION'); foreach ($groupIds as $position => $groupId) { $group = self::getComboGroupById($groupId); if ($group === null || $group->getComboSetId() !== $comboSetId || $group->getPosition() === $position) { continue; } $updated = true; $res = $wpdb->update( Schema::getComboSetGroupsTable(), [ 'position' => $position, 'updated_at' => Utils::getCurrentUTCDateTimeString(), ], ['id' => $groupId], ['%d', '%s'], ['%d'] ); if ($res === false) { $wpdb->query('ROLLBACK'); return Master::getErrorStore()->getErrorResponse(ErrorStore::INTERNAL_SERVER_ERROR); } } $wpdb->query('COMMIT'); return $updated; }