code cleanup

This commit is contained in:
Marc Delisle
2009-12-24 12:33:04 +00:00
parent 4fda8872e6
commit df8a359cff

View File

@@ -94,11 +94,11 @@ $serverid = time();
// check which replication is available and set $server_{master/slave}_status and assign values
foreach ($replication_types as $type) {
if (count(${"server_{$type}_replication"}) > 0)
if (count(${"server_{$type}_replication"}) > 0) {
${"server_{$type}_status"} = true;
else
} else {
${"server_{$type}_status"} = false;
}
if (${"server_{$type}_status"}) {
if ($type == "master") {
${"server_{$type}_Do_DB"} = explode(",", $server_master_replication[0]["Binlog_Do_DB"]);
@@ -134,12 +134,10 @@ function PMA_replication_strout($string, $table = false) {
*
* @return mixed output of PMA_DBI_try_query
*/
function PMA_replication_slave_control ($action, $control = null, $link = null)
{
function PMA_replication_slave_control($action, $control = null, $link = null) {
$action = strtoupper($action);
$control = strtoupper($control);
if ($action != "START" && $action != "STOP") {
return -1;
}
@@ -161,8 +159,7 @@ function PMA_replication_slave_control ($action, $control = null, $link = null)
*
* @return output of CHANGE MASTER mysql command
*/
function PMA_replication_slave_change_master($user, $password, $host, $port, $pos, $stop = true, $start = true, $link = null)
{
function PMA_replication_slave_change_master($user, $password, $host, $port, $pos, $stop = true, $start = true, $link = null) {
if ($stop) {
PMA_replication_slave_control("STOP", null, $link);
}
@@ -193,8 +190,7 @@ function PMA_replication_slave_change_master($user, $password, $host, $port, $po
*
* @return mixed $link mysql link on success
*/
function PMA_replication_connect_to_master($user, $password, $host = null, $port = null, $socket = null)
{
function PMA_replication_connect_to_master($user, $password, $host = null, $port = null, $socket = null) {
$server = array();
$server["host"] = $host;
$server["port"] = $port;
@@ -209,8 +205,7 @@ function PMA_replication_connect_to_master($user, $password, $host = null, $port
*
* @return array - containing File and Position in MySQL replication on master server, useful for PMA_replication_slave_change_master
*/
function PMA_replication_slave_bin_log_master($link = null)
{
function PMA_replication_slave_bin_log_master($link = null) {
$data = PMA_DBI_fetch_result('SHOW MASTER STATUS', null, null, $link);
$output = array();
@@ -229,8 +224,7 @@ function PMA_replication_slave_bin_log_master($link = null)
* @return array array of replicated databases
*/
function PMA_replication_master_replicated_dbs($link = null)
{
function PMA_replication_master_replicated_dbs($link = null) {
$data = PMA_DBI_fetch_result('SHOW MASTER STATUS', null, null, $link); // let's find out, which databases are replicated
$do_db = array();
@@ -272,8 +266,7 @@ function PMA_replication_master_replicated_dbs($link = null)
* @param boolean $data - if true, then data will be copied as well
*/
function PMA_replication_synchronize_db($db, $src_link, $trg_link, $data = true)
{
function PMA_replication_synchronize_db($db, $src_link, $trg_link, $data = true) {
$src_db = $trg_db = $db;
$src_connection = PMA_DBI_select_db($src_db, $src_link);
@@ -310,8 +303,9 @@ function PMA_replication_synchronize_db($db, $src_link, $trg_link, $data = true)
/**
*
* ********************************************* Comparing Data In the Matching Tables ******************************************
* *********************It is assumed that the matching tables are structurally and typely exactly the same *********************
* Comparing Data In the Matching Tables
* It is assumed that the matching tables are structurally
* and typely exactly the same
*/
$fields_num = array();
$matching_tables_fields = array();
@@ -323,13 +317,11 @@ function PMA_replication_synchronize_db($db, $src_link, $trg_link, $data = true)
$uncommon_tables_fields = array();
$matching_tables_num = sizeof($matching_tables);
for ($i=0; $i< sizeof($matching_tables); $i++)
{
for ($i = 0; $i < sizeof($matching_tables); $i++) {
PMA_dataDiffInTables($src_db, $trg_db, $src_link, $trg_link, $matching_tables, $matching_tables_fields, $update_array, $insert_array,
$delete_array, $fields_num, $i, $matching_tables_keys);
}
for ($j=0; $j< sizeof($source_tables_uncommon); $j++)
{
for ($j = 0; $j < sizeof($source_tables_uncommon); $j++) {
PMA_dataDiffInUncommonTables($source_tables_uncommon, $src_db, $src_link, $j, $row_count);
}
@@ -349,14 +341,7 @@ function PMA_replication_synchronize_db($db, $src_link, $trg_link, $data = true)
$remove_indexes_array = array();
$criteria = array('Field', 'Type', 'Null', 'Collation', 'Key', 'Default', 'Comment');
for ($counter = 0; $counter < $matching_tables_num; $counter++)
{
// PMA_structureDiffInTables($src_db, $trg_db, $src_link, $trg_link, $matching_tables, $source_columns,
// $target_columns, $alter_str_array, $add_column_array, $uncommon_columns, $criteria, $matching_tables_keys,
// $target_tables_keys, $matching_tables_fields, $counter);
//
// PMA_indexesDiffInTables($src_db, $trg_db, $src_link, $trg_link, $matching_tables, $source_indexes, $target_indexes,
// $add_indexes_array, $remove_indexes_array, $counter);
for ($counter = 0; $counter < $matching_tables_num; $counter++) {
PMA_structureDiffInTables($src_db, $trg_db, $src_link, $trg_link, $matching_tables, $source_columns,
$target_columns, $alter_str_array, $add_column_array, $uncommon_columns, $criteria, $target_tables_keys, $counter);
@@ -373,8 +358,7 @@ function PMA_replication_synchronize_db($db, $src_link, $trg_link, $data = true)
/**
* Generating Create Table query for all the non-matching tables present in Source but not in Target and populating tables.
*/
for($q = 0; $q < sizeof($source_tables_uncommon); $q++)
{
for($q = 0; $q < sizeof($source_tables_uncommon); $q++) {
if (isset($uncommon_tables[$q])) {
PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link, $source_tables_uncommon, $q, $uncommon_tables_fields, false);
}