$ver = '2011090989';
$db_host = "192.168.1.4";
$db_port = 8808;
$db_name = "fivetrees_manage";
$db_user = "root";
$db_pass = '123456';
$db = new mysqli($db_host, $db_user, $db_pass, $db_name, $db_port);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$sql = "
SELECT
`name` AS `id`,
`api_server` AS `node`,
`db_server` AS `db`
FROM
`servers`
WHERE
`cid` != 2 AND
`open` = 1 AND
`server_ver` != '$ver'
ORDER BY
`db_server`, `sid` ASC
";
$plan = '';
$plan_id = 0;
$last_db = '';
$counts = array();
if ($result = $db->query($sql)) {
while($row = $result->fetch_array(MYSQLI_ASSOC)) {
$server = substr($row['node'], 0, 5);
$code = "./shell-update {$row['id']} $server $ver\n";
if ($last_db != $row['db']) {
$plan_id = 1;
$last_db = $row['db'];
$counts[$plan_id] = 0;
file_put_contents("update_plan_$plan_id.sh", "");
}
$counts[$plan_id] = 1;
file_put_contents("update_plan_$plan_id.sh", $code, FILE_APPEND);
}
$result->close();
}
$db->close();
print_r($counts);
?>
阅读(1142) | 评论(1) | 转发(0) |