{$message}"); fclose($file); return true; } else return false; } $limit = isset($_REQUEST['c']) ? $_REQUEST['c'] : 0; if (empty($limit)) $limit = 1000; $p = ConnectParameter::NewParameter(MASTER_HOSTNAME, MASTER_HOSTPORT, MASTER_DATABASE, MASTER_USERNAME, MASTER_PASSWORD, MASTER_PERSISTENT, MASTER_CHARSET); /** @var IPDOHelper $reader */ $reader = new PDODelegator(DATABASE_TYPE); /** @var IPDOHelper $writer */ $writer = new PDODelegator(DATABASE_TYPE); $log = ''; if (!$reader->Connect($p)) { $log = JsonObjectToJsonString($reader->GetErrors()); OutputDebugMessage($log); exit($log); } if (!$writer->Connect($p)) { $log = JsonObjectToJsonString($writer->GetErrors()); OutputDebugMessage($log); exit($log); } $reader->request( function ($row) { /** @var IPDOHelper $db */ $db = $GLOBALS['writer']; $player_id = $row->player_id; $player_name = $row->player_name; $used_card = (array)JsonStringToJsonObject($row->room_type); $used_card = array_shift($used_card); $game_info = JsonStringToJsonObject($row->game_info); $player_list = isset($game_info->playerlist) ? $game_info->playerlist : null; if (!$player_list) return true; $winner = null; $integral = null; foreach ($player_list as $key => $value) { if (!$winner || intval($value[1]) > $integral) { $winner = $value[0]; $integral = intval($value[1]); } } if (strcasecmp($player_name, $winner) == 0) { $command = /** @lang text */ 'update ct_temp set used_card = ?, wins = 1, is_process = 1 where id = ?'; } else { $command = /** @lang text */ 'update ct_temp set used_card = ?, is_process = 1 where id = ?'; } if ($db->execute($command, $used_card, $row->id)) { echo 'the record id(', $row->id, ') processing success!
', PHP_EOL; } else { echo 'the record id(', $row->id, ') processing fail!
', PHP_EOL; } return true; }, /** @lang text */ 'select * from ct_temp where is_process = 0 limit ' . intval($limit) ); if (!$reader->isdone()) echo $reader->geterrorinfo(), PHP_EOL;