$params['name'] ]; $gameIds = [$params['id']]; if (isset($params['relation_game_id']) && $params['relation_game_id']) { $gameIds[] = $params['relation_game_id']; } $conditions['_logic'] = 'or'; $conditions['android_game_id'] = ['in', $gameIds]; $conditions['ios_game_id'] = ['in', $gameIds]; if ($params['sdk_version'] == 1) { $data['android_game_id'] = $params['id']; } elseif ($params['sdk_version'] == 2) { $data['ios_game_id'] = $params['id']; } $baseGame = M('base_game', 'tab_')->where($conditions)->find(); if (!$baseGame) { return M('base_game', 'tab_')->add($data); } else { return M('base_game', 'tab_')->where(['id' => $baseGame['id']])->save($data); } } }