diff --git a/Documentation.html b/Documentation.html
index 307a24a41c..42b906ef49 100644
--- a/Documentation.html
+++ b/Documentation.html
@@ -3298,9 +3298,9 @@ RewriteRule .* - [F]
$cfg['ThemeDefault'].
Under $cfg['ThemePath'], you
- should not delete the directory "original" or its underlying
+ should not delete the directory "pmahomme" or its underlying
structure, because this is the system theme used by phpMyAdmin.
- "original" contains all images and styles, for backwards
+ "pmahomme" contains all images and styles, for backwards
compatibility and for all themes that would not include images or css-files.
@@ -3313,7 +3313,7 @@ RewriteRule .* - [F]
- make a new subdirectory (for example "your_theme_name") under
$cfg['ThemePath']
(by default
themes)
- - copy the files and directories from "original" to
+
- copy the files and directories from "pmahomme" to
"your_theme_name"
- edit the css-files in "your_theme_name/css"
- put your new images in "your_theme_name/img"
@@ -3333,7 +3333,7 @@ RewriteRule .* - [F]
If you do not want to use your own symbols and buttons, remove the
directory "img" in "your_theme_name". phpMyAdmin will
- use the default icons and buttons (from the system-theme "original").
+ use the default icons and buttons (from the system-theme "pmahomme").
To select relation, click:
- ![[relation icon]](themes/original/img/pmd/help_relation.png)
+ ![[relation icon]](themes/pmahomme/img/pmd/help_relation.png)
The display column is shown in pink. To set/unset a column as the display column, click the "Choose column to display" icon, then click on the appropriate column name.
diff --git a/libraries/Theme.class.php b/libraries/Theme.class.php
index d0eccf7828..cdb91b5334 100644
--- a/libraries/Theme.class.php
+++ b/libraries/Theme.class.php
@@ -148,22 +148,30 @@ class PMA_Theme
*/
public function checkImgPath()
{
+ // try current theme first
if (is_dir($this->getPath() . '/img/')) {
$this->setImgPath($this->getPath() . '/img/');
return true;
- } elseif (is_dir($GLOBALS['cfg']['ThemePath'] . '/' . PMA_Theme_Manager::FALLBACK_THEME . '/img/')) {
- $this->setImgPath($GLOBALS['cfg']['ThemePath'] . '/' . PMA_Theme_Manager::FALLBACK_THEME . '/img/');
- return true;
- } else {
- trigger_error(
- sprintf(
- __('No valid image path for theme %s found!'),
- $this->getName()
- ),
- E_USER_ERROR
- );
- return false;
}
+
+ // try fallback theme
+ $fallback = $GLOBALS['cfg']['ThemePath'] . '/'
+ . PMA_Theme_Manager::FALLBACK_THEME
+ . '/img/';
+ if (is_dir($fallback)) {
+ $this->setImgPath($fallback);
+ return true;
+ }
+
+ // we failed
+ trigger_error(
+ sprintf(
+ __('No valid image path for theme %s found!'),
+ $this->getName()
+ ),
+ E_USER_ERROR
+ );
+ return false;
}
/**
@@ -301,14 +309,27 @@ class PMA_Theme
}
/**
- * Returns the path to images for the theme
+ * Returns the path to image for the theme.
+ * If filename is given, it possibly fallbacks to fallback
+ * theme for it if image does not exist.
+ *
+ * @param string $file file name for image
*
* @access public
* @return string image path for this theme
*/
- public function getImgPath()
+ public function getImgPath($file = null)
{
- return $this->img_path;
+ if (is_null($file)) {
+ return $this->img_path;
+ } else {
+ if (is_readable($this->img_path . $file)) {
+ return $this->img_path . $file;
+ } else {
+ return $GLOBALS['cfg']['ThemePath'] . '/'
+ . PMA_Theme_Manager::FALLBACK_THEME . '/img/' . $file;
+ }
+ }
}
/**
@@ -324,7 +345,7 @@ class PMA_Theme
*
* @see PMA_SQP_buildCssData()
*/
- public function SQP_buildCssRule($classname, $property, $value)
+ public function buildSQPCssRule($classname, $property, $value)
{
$str = '.' . $classname . ' {';
if ($value != '') {
@@ -347,17 +368,17 @@ class PMA_Theme
*
* @see PMA_SQP_buildCssRule()
*/
- public function SQP_buildCssData()
+ public function buildSQPCssData()
{
global $cfg;
$css_string = '';
foreach ($cfg['SQP']['fmtColor'] AS $key => $col) {
- $css_string .= $this->SQP_buildCssRule('syntax_' . $key, 'color', $col);
+ $css_string .= $this->buildSQPCssRule('syntax_' . $key, 'color', $col);
}
for ($i = 0; $i < 8; $i++) {
- $css_string .= $this->SQP_buildCssRule(
+ $css_string .= $this->buildSQPCssRule(
'syntax_indent' . $i, 'margin-left',
($i * $cfg['SQP']['fmtInd']) . $cfg['SQP']['fmtIndUnit']
);
@@ -376,7 +397,7 @@ class PMA_Theme
{
$success = true;
- echo $this->SQP_buildCssData();
+ echo $this->buildSQPCssData();
if ($GLOBALS['text_dir'] === 'ltr') {
$right = 'right';
@@ -388,7 +409,8 @@ class PMA_Theme
foreach ($this->_cssFiles as $file) {
$path = $this->getPath() . "/css/$file.css.php";
- $fallback = "./themes/" . PMA_Theme_Manager::FALLBACK_THEME . "/css/$file.css.php";
+ $fallback = "./themes/"
+ . PMA_Theme_Manager::FALLBACK_THEME . "/css/$file.css.php";
if (is_readable($path)) {
echo "\n/* FILE: $file.css.php */\n";
@@ -481,21 +503,33 @@ class PMA_Theme
{
$result = array();
// Opera 9.5+, IE 9
- $result[] = 'background-image: url(./themes/svg_gradient.php?from=' . $start_color . '&to=' . $end_color . ');';
+ $result[] = 'background-image: url(./themes/svg_gradient.php?from='
+ . $start_color . '&to=' . $end_color . ');';
$result[] = 'background-size: 100% 100%;';
// Safari 4-5, Chrome 1-9
- $result[] = 'background: -webkit-gradient(linear, left top, left bottom, from(#' . $start_color . '), to(#' . $end_color . '));';
+ $result[] = 'background: '
+ . '-webkit-gradient(linear, left top, left bottom, from(#'
+ . $start_color . '), to(#' . $end_color . '));';
// Safari 5.1, Chrome 10+
- $result[] = 'background: -webkit-linear-gradient(top, #' . $start_color . ', #' . $end_color . ');';
+ $result[] = 'background: -webkit-linear-gradient(top, #'
+ . $start_color . ', #' . $end_color . ');';
// Firefox 3.6+
- $result[] = 'background: -moz-linear-gradient(top, #' . $start_color . ', #' . $end_color . ');';
+ $result[] = 'background: -moz-linear-gradient(top, #'
+ . $start_color . ', #' . $end_color . ');';
// IE 10
- $result[] = 'background: -ms-linear-gradient(top, #' . $start_color . ', #' . $end_color . ');';
+ $result[] = 'background: -ms-linear-gradient(top, #'
+ . $start_color . ', #' . $end_color . ');';
// Opera 11.10
- $result[] = 'background: -o-linear-gradient(top, #' . $start_color . ', #' . $end_color . ');';
+ $result[] = 'background: -o-linear-gradient(top, #'
+ . $start_color . ', #' . $end_color . ');';
// IE 6-8
- if (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 6 && PMA_USR_BROWSER_VER <= 8) {
- $result[] = 'filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#' . $start_color . '", endColorstr="#' . $end_color . '");';
+ if (PMA_USR_BROWSER_AGENT == 'IE'
+ && PMA_USR_BROWSER_VER >= 6
+ && PMA_USR_BROWSER_VER <= 8
+ ) {
+ $result[] = 'filter: '
+ . 'progid:DXImageTransform.Microsoft.gradient(startColorstr="#'
+ . $start_color . '", endColorstr="#' . $end_color . '");';
}
return implode("\n", $result);
}
@@ -512,37 +546,48 @@ class PMA_Theme
}
$result[] = 'span.cm-keyword, span.cm-statement-verb {';
- $result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_reservedWord'] . ';';
+ $result[] = ' color: '
+ . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_reservedWord'] . ';';
$result[] = '}';
$result[] = 'span.cm-variable {';
- $result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_identifier'] . ';';
+ $result[] = ' color: '
+ . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_identifier'] . ';';
$result[] = '}';
$result[] = 'span.cm-comment {';
- $result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['comment'] . ';';
+ $result[] = ' color: '
+ . $GLOBALS['cfg']['SQP']['fmtColor']['comment'] . ';';
$result[] = '}';
$result[] = 'span.cm-mysql-string {';
- $result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['quote'] . ';';
+ $result[] = ' color: '
+ . $GLOBALS['cfg']['SQP']['fmtColor']['quote'] . ';';
$result[] = '}';
$result[] = 'span.cm-operator {';
- $result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['punct'] . ';';
+ $result[] = ' color: '
+ . $GLOBALS['cfg']['SQP']['fmtColor']['punct'] . ';';
$result[] = '}';
$result[] = 'span.cm-mysql-word {';
- $result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_identifier'] . ';';
+ $result[] = ' color: '
+ . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_identifier'] . ';';
$result[] = '}';
$result[] = 'span.cm-builtin {';
- $result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_functionName'] . ';';
+ $result[] = ' color: '
+ . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_functionName'] . ';';
$result[] = '}';
$result[] = 'span.cm-variable-2 {';
- $result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_columnType'] . ';';
+ $result[] = ' color: '
+ . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_columnType'] . ';';
$result[] = '}';
$result[] = 'span.cm-variable-3 {';
- $result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_columnAttrib'] . ';';
+ $result[] = ' color: '
+ . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_columnAttrib'] . ';';
$result[] = '}';
$result[] = 'span.cm-separator {';
- $result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['punct'] . ';';
+ $result[] = ' color: '
+ . $GLOBALS['cfg']['SQP']['fmtColor']['punct'] . ';';
$result[] = '}';
$result[] = 'span.cm-number {';
- $result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['digit_integer'] . ';';
+ $result[] = ' color: '
+ . $GLOBALS['cfg']['SQP']['fmtColor']['digit_integer'] . ';';
$result[] = '}';
return implode("\n", $result);
diff --git a/libraries/common.inc.php b/libraries/common.inc.php
index f3b0b183bc..c3a0f6a2f8 100644
--- a/libraries/common.inc.php
+++ b/libraries/common.inc.php
@@ -571,7 +571,7 @@ $GLOBALS['js_include'][] = 'update-location.js';
/**
* holds an array of javascript code snippets to be included in the HTML header
- * Can be used with PMA_AddJSCode() to pass on js variables to the browser.
+ * Can be used with PMA_addJSCode() to pass on js variables to the browser.
* @global array $js_script
*/
$GLOBALS['js_script'] = array();
diff --git a/libraries/common.lib.php b/libraries/common.lib.php
index be9d13a8a3..50b57a4085 100644
--- a/libraries/common.lib.php
+++ b/libraries/common.lib.php
@@ -361,7 +361,7 @@ function PMA_formatSql($parsed_sql, $unparsed_sql = '')
return $formatted_sql;
}
- $formatted_sql = '';
+ $formatted_sql = '';
switch ($cfg['SQP']['fmtType']) {
case 'none':
@@ -683,10 +683,10 @@ function PMA_mysqlDie(
// modified to show the help on error-returns
// (now error-messages-server)
$error_msg .= '
' . "\n"
- . ' ' . __('MySQL said: ') . ''
- . PMA_showMySQLDocu('Error-messages-server', 'Error-messages-server')
- . "\n"
- . '
' . "\n";
+ . ' ' . __('MySQL said: ') . ''
+ . PMA_showMySQLDocu('Error-messages-server', 'Error-messages-server')
+ . "\n"
+ . '' . "\n";
// The error message will be displayed within a CODE segment.
// To preserve original formatting, but allow wordwrapping,
@@ -812,7 +812,8 @@ function PMA_getTableList($db, $tables = null, $limit_offset = 0,
$group_name_full = '';
$parts_cnt = count($parts) - 1;
while ($i < $parts_cnt
- && $i < $GLOBALS['cfg']['LeftFrameTableLevel']) {
+ && $i < $GLOBALS['cfg']['LeftFrameTableLevel']
+ ) {
$group_name = $parts[$i] . $sep;
$group_name_full .= $group_name;
@@ -1349,7 +1350,7 @@ function PMA_getMessage(
}
return $retval;
-
+
} // end of the 'PMA_getMessage()' function
/**
@@ -1977,17 +1978,17 @@ function PMA_linkOrButton($url, $message, $tag_params = array(),
function PMA_splitURLQuery($url)
{
// decode encoded url separators
- $separator = PMA_get_arg_separator();
+ $separator = PMA_get_arg_separator();
// on most places separator is still hard coded ...
if ($separator !== '&') {
// ... so always replace & with $separator
- $url = str_replace(htmlentities('&'), $separator, $url);
- $url = str_replace('&', $separator, $url);
+ $url = str_replace(htmlentities('&'), $separator, $url);
+ $url = str_replace('&', $separator, $url);
}
- $url = str_replace(htmlentities($separator), $separator, $url);
+ $url = str_replace(htmlentities($separator), $separator, $url);
// end decode
- $url_parts = parse_url($url);
+ $url_parts = parse_url($url);
return explode($separator, $url_parts['query']);
}
@@ -2653,9 +2654,9 @@ function PMA_getCheckbox($html_field_name, $label, $checked, $onclick)
function PMA_getRadioFields($html_field_name, $choices, $checked_choice = '',
$line_break = true, $escape_label = true, $class=''
) {
-
+
$radio_html = '';
-
+
foreach ($choices as $choice_value => $choice_label) {
if (! empty($class)) {
$radio_html .= '';
@@ -2681,9 +2682,9 @@ function PMA_getRadioFields($html_field_name, $choices, $checked_choice = '',
}
$radio_html .= "\n";
}
-
+
return $radio_html;
-
+
}
/**
@@ -2723,9 +2724,9 @@ function PMA_getDropdown($select_name, $choices, $active_choice, $id)
*
* @param string $id the id of the
on which to apply the effect
* @param string $message the message to show as a link
- *
+ *
* @return string html div element
- *
+ *
*/
function PMA_getDivForSliderEffect($id, $message)
{
@@ -2740,7 +2741,7 @@ function PMA_getDivForSliderEffect($id, $message)
* method maybe by using an additional param, the id of the div to
* append to
*/
-
+
return '
diff --git a/libraries/server_synchronize.lib.php b/libraries/server_synchronize.lib.php
index 1d17fbad41..c1349ef74c 100644
--- a/libraries/server_synchronize.lib.php
+++ b/libraries/server_synchronize.lib.php
@@ -26,10 +26,11 @@ if (! defined('PHPMYADMIN')) {
* @return nothing
*/
function PMA_getMatchingTables($trg_tables, $src_tables, &$matching_tables,
-&$uncommon_source_tables) {
- for ($k=0; $k< sizeof($src_tables); $k++) {
+ &$uncommon_source_tables
+) {
+ for ($k=0; $k< count($src_tables); $k++) {
$present_in_target = false;
- for ($l=0; $l < sizeof($trg_tables); $l++) {
+ for ($l=0; $l < count($trg_tables); $l++) {
if ($src_tables[$k] === $trg_tables[$l]) {
$present_in_target = true;
$matching_tables[] = $src_tables[$k];
@@ -54,10 +55,11 @@ function PMA_getMatchingTables($trg_tables, $src_tables, &$matching_tables,
* @return nothing
*/
function PMA_getNonMatchingTargetTables($trg_tables, $matching_tables,
-&$uncommon_target_tables) {
- for ($c=0; $c
1) {
- for ($k=0; $k < sizeof($is_key); $k++) {
+ if (count($is_key) == 1) {
+ $trg_select_query .= PMA_backquote($is_key[0])
+ . "='" . $source_result_set[$j] . "'";
+ } elseif (count($is_key) > 1) {
+ for ($k=0; $k < count($is_key); $k++) {
$trg_select_query .= PMA_backquote($is_key[$k])
. "='" . $source_result_set[$j][$is_key[$k]] . "'";
- if ($k < (sizeof($is_key)-1)) {
+ if ($k < (count($is_key)-1)) {
$trg_select_query .= " AND ";
}
}
}
- $target_result_set = PMA_DBI_fetch_result($trg_select_query, null, null, $trg_link);
+ $target_result_set = PMA_DBI_fetch_result(
+ $trg_select_query,
+ null,
+ null,
+ $trg_link
+ );
if ($target_result_set) {
// Fetch the row from the source server to do a comparison
- $src_select_query = "SELECT * FROM " . PMA_backquote($src_db) . "."
- . PMA_backquote($matching_table[$matching_table_index]) . " WHERE ";
+ $src_select_query = "SELECT * FROM "
+ . PMA_backquote($src_db) . "."
+ . PMA_backquote($matching_table[$matching_table_index])
+ . " WHERE ";
- if (sizeof($is_key) == 1) {
+ if (count($is_key) == 1) {
$src_select_query .= PMA_backquote($is_key[0])
. "='" . $source_result_set[$j] . "'";
- } elseif (sizeof($is_key) > 1) {
- for ($k=0; $k< sizeof($is_key); $k++) {
+ } elseif (count($is_key) > 1) {
+ for ($k=0; $k< count($is_key); $k++) {
$src_select_query .= PMA_backquote($is_key[$k])
. "='" . $source_result_set[$j][$is_key[$k]] . "'";
- if ($k < (sizeof($is_key) - 1)) {
+ if ($k < (count($is_key) - 1)) {
$src_select_query .= " AND ";
}
}
}
- $src_result_set = PMA_DBI_fetch_result($src_select_query, null, null, $src_link);
+ $src_result_set = PMA_DBI_fetch_result(
+ $src_select_query,
+ null,
+ null,
+ $src_link
+ );
/**
- * Comparing each corresponding field of the source and target matching rows.
- * Placing the primary key, value of primary key, field to be updated, and the
- * new value of field to be updated in each row of the update array.
+ * Comparing each corresponding field of the source and target
+ * matching rows. Placing the primary key, value of primary
+ * key, field to be updated, and the new value of field to
+ * be updated in each row of the update array.
*/
for ($m = 0; ($m < $fields_num[$matching_table_index]) && ($starting_index == 0) ; $m++) {
if (isset($src_result_set[0][$fld[$m]])) {
if (isset($target_result_set[0][$fld[$m]])) {
if (($src_result_set[0][$fld[$m]] != $target_result_set[0][$fld[$m]]) && (! (in_array($fld[$m], $is_key)))) {
- if (sizeof($is_key) == 1) {
+ if (count($is_key) == 1) {
if ($source_result_set[$j]) {
$update_array[$matching_table_index][$update_row][$is_key[0]] = $source_result_set[$j];
}
- } elseif (sizeof($is_key) > 1) {
- for ($n=0; $n < sizeof($is_key); $n++) {
+ } elseif (count($is_key) > 1) {
+ for ($n=0; $n < count($is_key); $n++) {
if (isset($src_result_set[0][$is_key[$n]])) {
$update_array[$matching_table_index][$update_row][$is_key[$n]] = $src_result_set[0][$is_key[$n]];
}
@@ -226,12 +243,12 @@ function PMA_dataDiffInTables($src_db, $trg_db, $src_link, $trg_link,
$update_row++;
}
} else {
- if (sizeof($is_key) == 1) {
+ if (count($is_key) == 1) {
if ($source_result_set[$j]) {
$update_array[$matching_table_index][$update_row][$is_key[0]] = $source_result_set[$j];
}
- } elseif (sizeof($is_key) > 1) {
- for ($n = 0; $n < sizeof($is_key); $n++) {
+ } elseif (count($is_key) > 1) {
+ for ($n = 0; $n < count($is_key); $n++) {
if (isset($src_result_set[0][$is_key[$n]])) {
$update_array[$matching_table_index][$update_row][$is_key[$n]] = $src_result_set[0][$is_key[$n]];
}
@@ -277,14 +294,15 @@ function PMA_dataDiffInTables($src_db, $trg_db, $src_link, $trg_link,
}
} else {
/**
- * Placing the primary key, and the value of primary key of the row that is to be inserted in the target table
+ * Placing the primary key, and the value of primary key of the
+ * row that is to be inserted in the target table
*/
- if (sizeof($is_key) == 1) {
+ if (count($is_key) == 1) {
if (isset($source_result_set[$j])) {
$insert_array[$matching_table_index][$insert_row][$is_key[0]] = $source_result_set[$j];
}
- } elseif (sizeof($is_key) > 1) {
- for ($l = 0; $l < sizeof($is_key); $l++) {
+ } elseif (count($is_key) > 1) {
+ for ($l = 0; $l < count($is_key); $l++) {
if (isset($source_result_set[$j][$matching_tables_fields[$matching_table_index][$l]])) {
$insert_array[$matching_table_index][$insert_row][$is_key[$l]] = $source_result_set[$j][$matching_tables_fields[$matching_table_index][$l]];
}
@@ -294,15 +312,17 @@ function PMA_dataDiffInTables($src_db, $trg_db, $src_link, $trg_link,
}
} else {
/**
- * Placing the primary key, and the value of primary key of the row that is to be inserted in the target table
- * This condition is met when there is an additional column in the source table
+ * Placing the primary key, and the value of primary key of the
+ * row that is to be inserted in the target table. This
+ * condition is met when there is an additional column in the
+ * source table
*/
- if (sizeof($is_key) == 1) {
+ if (count($is_key) == 1) {
if (isset($source_result_set[$j])) {
$insert_array[$matching_table_index][$insert_row][$is_key[0]] = $source_result_set[$j];
}
- } elseif (sizeof($is_key) > 1) {
- for ($l = 0; $l < sizeof($is_key); $l++) {
+ } elseif (count($is_key) > 1) {
+ for ($l = 0; $l < count($is_key); $l++) {
if (isset($source_result_set[$j][$matching_tables_fields[$matching_table_index][$l]])) {
$insert_array[$matching_table_index][$insert_row][$is_key[$l]] = $source_result_set[$j][$matching_tables_fields[$matching_table_index][$l]];
}
@@ -339,7 +359,7 @@ function PMA_findDeleteRowsFromTargetTables(&$delete_array, $matching_table,
$source_key_values = PMA_getColumnValues($src_db, $matching_table[$matching_table_index], $src_keys[$matching_table_index], $src_link);
}
$all_keys_match = 1;
- for ($a = 0; $a < sizeof($trg_keys[$matching_table_index]); $a++) {
+ for ($a = 0; $a < count($trg_keys[$matching_table_index]); $a++) {
if (isset($trg_keys[$matching_table_index][$a])) {
if (! (in_array($trg_keys[$matching_table_index][$a], $src_keys[$matching_table_index]))) {
$all_keys_match = 0;
@@ -352,24 +372,24 @@ function PMA_findDeleteRowsFromTargetTables(&$delete_array, $matching_table,
}
}
if (isset($trg_keys[$matching_table_index])) {
- if ((sizeof($trg_keys[$matching_table_index]) == 1) && $all_keys_match) {
+ if ((count($trg_keys[$matching_table_index]) == 1) && $all_keys_match) {
$row = 0;
if (isset($target_key_values)) {
- for ($i = 0; $i < sizeof($target_key_values); $i++) {
+ for ($i = 0; $i < count($target_key_values); $i++) {
if (! (in_array($target_key_values[$i], $source_key_values))) {
$delete_array[$matching_table_index][$row] = $target_key_values[$i];
$row++;
}
}
}
- } elseif ((sizeof($trg_keys[$matching_table_index]) > 1) && $all_keys_match) {
+ } elseif ((count($trg_keys[$matching_table_index]) > 1) && $all_keys_match) {
$row = 0;
if (isset($target_key_values)) {
- for ($i = 0; $i < sizeof($target_key_values); $i++) {
+ for ($i = 0; $i < count($target_key_values); $i++) {
$is_present = false;
- for ($j = 0; $j < sizeof($source_key_values) && ($is_present == false) ; $j++) {
+ for ($j = 0; $j < count($source_key_values) && ($is_present == false) ; $j++) {
$check = true;
- for ($k = 0; $k < sizeof($trg_keys[$matching_table_index]); $k++) {
+ for ($k = 0; $k < count($trg_keys[$matching_table_index]); $k++) {
if ($target_key_values[$i][$trg_keys[$matching_table_index][$k]] != $source_key_values[$j][$trg_keys[$matching_table_index][$k]]) {
$check = false;
}
@@ -379,7 +399,7 @@ function PMA_findDeleteRowsFromTargetTables(&$delete_array, $matching_table,
}
}
if (! ($is_present)) {
- for ($l = 0; $l < sizeof($trg_keys[$matching_table_index]); $l++) {
+ for ($l = 0; $l < count($trg_keys[$matching_table_index]); $l++) {
$delete_array[$matching_table_index][$row][$trg_keys[$matching_table_index][$l]] = $target_key_values[$i][$trg_keys[$matching_table_index][$l]];
}
$row++;
@@ -405,7 +425,8 @@ function PMA_findDeleteRowsFromTargetTables(&$delete_array, $matching_table,
*/
function PMA_dataDiffInUncommonTables($source_tables_uncommon, $src_db, $src_link, $index, &$row_count)
{
- $query = "SELECT COUNT(*) FROM " . PMA_backquote($src_db) . "." . PMA_backquote($source_tables_uncommon[$index]);
+ $query = "SELECT COUNT(*) FROM " . PMA_backquote($src_db) . "."
+ . PMA_backquote($source_tables_uncommon[$index]);
$rows = PMA_DBI_fetch_result($query, null, null, $src_link);
$row_count[$index] = $rows[0];
}
@@ -414,17 +435,17 @@ function PMA_dataDiffInUncommonTables($source_tables_uncommon, $src_db, $src_lin
* PMA_updateTargetTables() sets the updated field values to
* target table rows using $update_array[$matching_table_index]
*
- * @param array $table Matching tables' names
- * @param array $update_array A three dimensional array containing field
- * value updates required for each matching
- * table
- * @param string $src_db Name of source database
- * @param string $trg_db Name of target database
- * @param mixed $trg_link Connection established with target server
- * @param int $matching_table_index index of matching table in
- * matching_table_array
- * @param array $matching_table_keys matching keys for table
- * @param bool $display whether to display query
+ * @param array $table Matching tables' names
+ * @param array $update_array A three dimensional array containing field
+ * value updates required for each matching
+ * table
+ * @param string $src_db Name of source database
+ * @param string $trg_db Name of target database
+ * @param mixed $trg_link Connection established with target server
+ * @param int $matching_table_index index of matching table in
+ * matching_table_array
+ * @param array $matching_table_keys matching keys for table
+ * @param bool $display whether to display query
*
* @return nothing
*/
@@ -433,12 +454,12 @@ function PMA_updateTargetTables(
$trg_link, $matching_table_index, $matching_table_keys, $display
) {
if (isset($update_array[$matching_table_index])) {
- if (sizeof($update_array[$matching_table_index])) {
+ if (count($update_array[$matching_table_index])) {
- for ($update_row = 0; $update_row < sizeof($update_array[$matching_table_index]); $update_row++) {
+ for ($update_row = 0; $update_row < count($update_array[$matching_table_index]); $update_row++) {
if (isset($update_array[$matching_table_index][$update_row])) {
- $update_fields_num = sizeof($update_array[$matching_table_index][$update_row])-sizeof($matching_table_keys[$matching_table_index]);
+ $update_fields_num = count($update_array[$matching_table_index][$update_row])-count($matching_table_keys[$matching_table_index]);
if ($update_fields_num > 0) {
$query = "UPDATE " . PMA_backquote($trg_db) . "." .PMA_backquote($table[$matching_table_index]) . " SET ";
@@ -452,11 +473,11 @@ function PMA_updateTargetTables(
}
$query .= " WHERE ";
if (isset($matching_table_keys[$matching_table_index])) {
- for ($key = 0; $key < sizeof($matching_table_keys[$matching_table_index]); $key++) {
+ for ($key = 0; $key < count($matching_table_keys[$matching_table_index]); $key++) {
if (isset($matching_table_keys[$matching_table_index][$key])) {
$query .= PMA_backquote($matching_table_keys[$matching_table_index][$key]) . "='" . $update_array[$matching_table_index][$update_row][$matching_table_keys[$matching_table_index][$key]] . "'";
}
- if ($key < (sizeof($matching_table_keys[$matching_table_index]) - 1)) {
+ if ($key < (count($matching_table_keys[$matching_table_index]) - 1)) {
$query .= " AND ";
}
}
@@ -488,20 +509,32 @@ function PMA_updateTargetTables(
* @param mixed $trg_link connection established with target server
* @param array $table_fields field names of a table
* @param array &$array_insert
- * @param int $matching_table_index index of matching table in matching_table_array
- * @param array $matching_tables_keys field names that are keys in the matching table
+ * @param int $matching_table_index index of matching table in
+ * matching_table_array
+ * @param array $matching_tables_keys field names that are keys in the matching
+ * table
* @param array $source_columns source column information
- * @param array &$add_column_array column names that are to be added in target table
- * @param array $criteria criteria like type, null, collation, default etc
- * @param array $target_tables_keys field names that are keys in the target table
- * @param array $uncommon_tables table names that are present in source db but not in targt db
+ * @param array &$add_column_array column names that are to be added in
+ * target table
+ * @param array $criteria criteria like type, null, collation,
+ * default etc
+ * @param array $target_tables_keys field names that are keys in the target
+ * table
+ * @param array $uncommon_tables table names that are present in source db
+ * but not in targt db
* @param array &$uncommon_tables_fields field names of the uncommon tables
- * @param array $uncommon_cols column names that are present in target table and not in source table
+ * @param array $uncommon_cols column names that are present in target
+ * table and not in source table
* @param array &$alter_str_array column names that are to be altered
- * @param array &$source_indexes column names on which indexes are made in source table
- * @param array &$target_indexes column names on which indexes are made in target table
- * @param array &$add_indexes_array column names on which index is to be added in target table
- * @param array &$alter_indexes_array column names whose indexes are to be altered. Only index name and uniqueness of an index can be changed
+ * @param array &$source_indexes column names on which indexes are made
+ * in source table
+ * @param array &$target_indexes column names on which indexes are made
+ * in target table
+ * @param array &$add_indexes_array column names on which index is to be
+ * added in target table
+ * @param array &$alter_indexes_array column names whose indexes are to be
+ * altered. Only index name and uniqueness
+ * of an index can be changed
* @param array &$delete_array rows that are to be deleted
* @param array &$update_array rows that are to be updated in target
* @param bool $display whether to display query
@@ -516,16 +549,16 @@ function PMA_insertIntoTargetTable($matching_table, $src_db, $trg_db, $src_link,
&$alter_indexes_array, &$delete_array, &$update_array, $display
) {
if (isset($array_insert[$matching_table_index])) {
- if (sizeof($array_insert[$matching_table_index])) {
- for ($insert_row = 0; $insert_row< sizeof($array_insert[$matching_table_index]); $insert_row++) {
+ if (count($array_insert[$matching_table_index])) {
+ for ($insert_row = 0; $insert_row< count($array_insert[$matching_table_index]); $insert_row++) {
if (isset($array_insert[$matching_table_index][$insert_row][$matching_tables_keys[$matching_table_index][0]])) {
$select_query = "SELECT * FROM " . PMA_backquote($src_db) . "." . PMA_backquote($matching_table[$matching_table_index]) . " WHERE ";
- for ($i = 0; $i < sizeof($matching_tables_keys[$matching_table_index]); $i++) {
+ for ($i = 0; $i < count($matching_tables_keys[$matching_table_index]); $i++) {
$select_query .= $matching_tables_keys[$matching_table_index][$i] . "='";
$select_query .= $array_insert[$matching_table_index][$insert_row][$matching_tables_keys[$matching_table_index][$i]] . "'" ;
- if ($i < (sizeof($matching_tables_keys[$matching_table_index]) - 1)) {
+ if ($i < (count($matching_tables_keys[$matching_table_index]) - 1)) {
$select_query.= " AND ";
}
}
@@ -533,7 +566,7 @@ function PMA_insertIntoTargetTable($matching_table, $src_db, $trg_db, $src_link,
$result = PMA_DBI_fetch_result($select_query, null, null, $src_link);
$insert_query = "INSERT INTO " . PMA_backquote($trg_db) . "." . PMA_backquote($matching_table[$matching_table_index]) ." (";
- for ($field_index = 0; $field_index < sizeof($table_fields[$matching_table_index]); $field_index++) {
+ for ($field_index = 0; $field_index < count($table_fields[$matching_table_index]); $field_index++) {
$insert_query .= PMA_backquote($table_fields[$matching_table_index][$field_index]);
$is_fk_query = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = '" . $trg_db ."'
@@ -541,35 +574,52 @@ function PMA_insertIntoTargetTable($matching_table, $src_db, $trg_db, $src_link,
$table_fields[$matching_table_index][$field_index] . "' AND TABLE_NAME <> REFERENCED_TABLE_NAME;" ;
$is_fk_result = PMA_DBI_fetch_result($is_fk_query, null, null, $trg_link);
- if (sizeof($is_fk_result) > 0) {
- for ($j = 0; $j < sizeof($is_fk_result); $j++) {
+ if (count($is_fk_result) > 0) {
+ for ($j = 0; $j < count($is_fk_result); $j++) {
$table_index = array_keys($matching_table, $is_fk_result[$j]['REFERENCED_TABLE_NAME']);
if (isset($alter_str_array[$table_index[0]])) {
PMA_alterTargetTableStructure(
- $trg_db, $trg_link, $matching_tables, $source_columns, $alter_str_array, $matching_tables_fields,
- $criteria, $matching_tables_keys, $target_tables_keys, $table_index[0], $display
+ $trg_db, $trg_link, $matching_tables,
+ $source_columns, $alter_str_array,
+ $matching_tables_fields,
+ $criteria, $matching_tables_keys,
+ $target_tables_keys, $table_index[0],
+ $display
);
unset($alter_str_array[$table_index[0]]);
}
if (isset($uncommon_columns[$table_index[0]])) {
- PMA_removeColumnsFromTargetTable($trg_db, $trg_link, $matching_tables, $uncommon_columns, $table_index[0], $display);
+ PMA_removeColumnsFromTargetTable(
+ $trg_db, $trg_link, $matching_tables,
+ $uncommon_columns, $table_index[0], $display
+ );
unset($uncommon_columns[$table_index[0]]);
}
if (isset($add_column_array[$table_index[0]])) {
PMA_findDeleteRowsFromTargetTables(
- $delete_array, $matching_tables, $table_index[0], $target_tables_keys,
- $matching_tables_keys, $trg_db, $trg_link, $src_db, $src_link
+ $delete_array, $matching_tables,
+ $table_index[0], $target_tables_keys,
+ $matching_tables_keys, $trg_db,
+ $trg_link, $src_db, $src_link
);
if (isset($delete_array[$table_index[0]])) {
- PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables, $table_index[0], $target_tables_keys, $delete_array, $display);
+ PMA_deleteFromTargetTable(
+ $trg_db, $trg_link, $matching_tables,
+ $table_index[0], $target_tables_keys,
+ $delete_array, $display
+ );
unset($delete_array[$table_index[0]]);
}
PMA_addColumnsInTargetTable(
- $src_db, $trg_db, $src_link, $trg_link, $matching_tables, $source_columns, $add_column_array,
- $matching_tables_fields, $criteria, $matching_tables_keys, $target_tables_keys, $uncommon_tables,
- $uncommon_tables_fields, $table_index[0], $uncommon_cols, $display
+ $src_db, $trg_db, $src_link, $trg_link,
+ $matching_tables, $source_columns,
+ $add_column_array, $matching_tables_fields,
+ $criteria, $matching_tables_keys,
+ $target_tables_keys, $uncommon_tables,
+ $uncommon_tables_fields, $table_index[0],
+ $uncommon_cols, $display
);
unset($add_column_array[$table_index[0]]);
}
@@ -578,8 +628,11 @@ function PMA_insertIntoTargetTable($matching_table, $src_db, $trg_db, $src_link,
|| isset($alter_indexes_array[$table_index[0]])
) {
PMA_applyIndexesDiff(
- $trg_db, $trg_link, $matching_tables, $source_indexes, $target_indexes, $add_indexes_array,
- $alter_indexes_array, $remove_indexes_array, $table_index[0], $display
+ $trg_db, $trg_link, $matching_tables,
+ $source_indexes, $target_indexes,
+ $add_indexes_array, $alter_indexes_array,
+ $remove_indexes_array, $table_index[0],
+ $display
);
unset($add_indexes_array[$table_index[0]]);
@@ -588,37 +641,46 @@ function PMA_insertIntoTargetTable($matching_table, $src_db, $trg_db, $src_link,
}
if (isset($update_array[$table_index[0]])) {
PMA_updateTargetTables(
- $matching_tables, $update_array, $src_db, $trg_db, $trg_link,
- $table_index[0], $matching_table_keys, $display
+ $matching_tables, $update_array,
+ $src_db, $trg_db, $trg_link,
+ $table_index[0], $matching_table_keys,
+ $display
);
unset($update_array[$table_index[0]]);
}
if (isset($array_insert[$table_index[0]])) {
PMA_insertIntoTargetTable(
- $matching_table, $src_db, $trg_db, $src_link, $trg_link, $table_fields, $array_insert, $table_index[0],
- $matching_tables_keys, $source_columns, $add_column_array, $criteria, $target_tables_keys, $uncommon_tables,
- $uncommon_tables_fields, $uncommon_cols, $alter_str_array, $source_indexes, $target_indexes, $add_indexes_array,
- $alter_indexes_array, $delete_array, $update_array, $display
+ $matching_table, $src_db, $trg_db,
+ $src_link, $trg_link, $table_fields,
+ $array_insert, $table_index[0],
+ $matching_tables_keys, $source_columns,
+ $add_column_array, $criteria,
+ $target_tables_keys, $uncommon_tables,
+ $uncommon_tables_fields, $uncommon_cols,
+ $alter_str_array, $source_indexes,
+ $target_indexes, $add_indexes_array,
+ $alter_indexes_array, $delete_array,
+ $update_array, $display
);
unset($array_insert[$table_index[0]]);
}
}
}
- if ($field_index < sizeof($table_fields[$matching_table_index])-1) {
+ if ($field_index < count($table_fields[$matching_table_index])-1) {
$insert_query .= ", ";
}
}
$insert_query .= ") VALUES(";
- if (sizeof($table_fields[$matching_table_index]) == 1) {
+ if (count($table_fields[$matching_table_index]) == 1) {
$insert_query .= "'" . PMA_sqlAddSlashes($result[0]) . "'";
} else {
- for ($field_index = 0; $field_index < sizeof($table_fields[$matching_table_index]); $field_index++) {
+ for ($field_index = 0; $field_index < count($table_fields[$matching_table_index]); $field_index++) {
if (isset($result[0][$table_fields[$matching_table_index][$field_index]])) {
$insert_query .= "'" . PMA_sqlAddSlashes($result[0][$table_fields[$matching_table_index][$field_index]]) . "'";
} else {
$insert_query .= "'NULL'";
}
- if ($field_index < (sizeof($table_fields[$matching_table_index])) - 1) {
+ if ($field_index < (count($table_fields[$matching_table_index])) - 1) {
$insert_query .= " ," ;
}
}
@@ -654,7 +716,13 @@ function PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link,
&$uncommon_tables, $table_index, &$uncommon_tables_fields, $display
) {
if (isset($uncommon_tables[$table_index])) {
- $fields_result = PMA_DBI_get_columns($src_db, $uncommon_tables[$table_index], null, true, $src_link);
+ $fields_result = PMA_DBI_get_columns(
+ $src_db,
+ $uncommon_tables[$table_index],
+ null,
+ true,
+ $src_link
+ );
$fields = array();
foreach ($fields_result as $each_field) {
$field_name = $each_field['Field'];
@@ -662,7 +730,13 @@ function PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link,
}
$uncommon_tables_fields[$table_index] = $fields;
- $Create_Query = PMA_DBI_fetch_value("SHOW CREATE TABLE " . PMA_backquote($src_db) . '.' . PMA_backquote($uncommon_tables[$table_index]), 0, 1, $src_link);
+ $Create_Query = PMA_DBI_fetch_value(
+ "SHOW CREATE TABLE " . PMA_backquote($src_db) . '.'
+ . PMA_backquote($uncommon_tables[$table_index]),
+ 0,
+ 1,
+ $src_link
+ );
// Replace the src table name with a `dbname`.`tablename`
$Create_Table_Query = preg_replace(
@@ -676,8 +750,8 @@ function PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link,
AND TABLE_NAME = '" . $uncommon_tables[$table_index] . "' AND TABLE_NAME <> REFERENCED_TABLE_NAME;" ;
$is_fk_result = PMA_DBI_fetch_result($is_fk_query, null, null, $src_link);
- if (sizeof($is_fk_result) > 0) {
- for ($j = 0; $j < sizeof($is_fk_result); $j++) {
+ if (count($is_fk_result) > 0) {
+ for ($j = 0; $j < count($is_fk_result); $j++) {
if (in_array($is_fk_result[$j]['REFERENCED_TABLE_NAME'], $uncommon_tables)) {
$table_index = array_keys($uncommon_tables, $is_fk_result[$j]['REFERENCED_TABLE_NAME']);
PMA_createTargetTables($src_db, $trg_db, $trg_link, $src_link, $uncommon_tables, $table_index[0], $uncommon_tables_fields, $display);
@@ -713,10 +787,17 @@ function PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link,
function PMA_populateTargetTables($src_db, $trg_db, $src_link, $trg_link,
$uncommon_tables, $table_index, $uncommon_tables_fields, $display
) {
- $display = false; // todo: maybe display some of the queries if they are not too numerous
- $unbuffered_result = PMA_DBI_try_query('SELECT * FROM ' . PMA_backquote($src_db) . '.' . PMA_backquote($uncommon_tables[$table_index]), $src_link, PMA_DBI_QUERY_UNBUFFERED);
+ // @todo: maybe display some of the queries if they are not too numerous
+ $display = false;
+ $unbuffered_result = PMA_DBI_try_query(
+ 'SELECT * FROM ' . PMA_backquote($src_db) . '.'
+ . PMA_backquote($uncommon_tables[$table_index]),
+ $src_link,
+ PMA_DBI_QUERY_UNBUFFERED
+ );
if (false !== $unbuffered_result) {
- $insert_query = 'INSERT INTO ' . PMA_backquote($trg_db) . '.' .PMA_backquote($uncommon_tables[$table_index]) . ' VALUES';
+ $insert_query = 'INSERT INTO ' . PMA_backquote($trg_db) . '.'
+ . PMA_backquote($uncommon_tables[$table_index]) . ' VALUES';
while ($one_row = PMA_DBI_fetch_row($unbuffered_result)) {
$insert_query .= '(';
$key_of_last_value = count($one_row) - 1;
@@ -750,21 +831,21 @@ function PMA_populateTargetTables($src_db, $trg_db, $src_link, $trg_link,
*
* @return nothing
*/
-function PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables, $table_index,
- $target_tables_keys, $delete_array, $display
+function PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables,
+ $table_index, $target_tables_keys, $delete_array, $display
) {
- for ($i = 0; $i < sizeof($delete_array[$table_index]); $i++) {
+ for ($i = 0; $i < count($delete_array[$table_index]); $i++) {
if (isset($target_tables_keys[$table_index])) {
$delete_query = 'DELETE FROM ' . PMA_backquote($trg_db) . '.' .PMA_backquote($matching_tables[$table_index]) . ' WHERE ';
- for ($y = 0; $y < sizeof($target_tables_keys[$table_index]); $y++) {
+ for ($y = 0; $y < count($target_tables_keys[$table_index]); $y++) {
$delete_query .= PMA_backquote($target_tables_keys[$table_index][$y]) . " = '";
- if (sizeof($target_tables_keys[$table_index]) == 1) {
+ if (count($target_tables_keys[$table_index]) == 1) {
$delete_query .= $delete_array[$table_index][$i] . "'";
- } elseif (sizeof($target_tables_keys[$table_index]) > 1) {
+ } elseif (count($target_tables_keys[$table_index]) > 1) {
$delete_query .= $delete_array[$table_index][$i][$target_tables_keys[$table_index][$y]] . "'";
}
- if ($y < (sizeof($target_tables_keys[$table_index]) - 1)) {
+ if ($y < (count($target_tables_keys[$table_index]) - 1)) {
$delete_query .= ' AND ';
}
$pk_query = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_SCHEMA = '" . $trg_db . "'
@@ -772,11 +853,17 @@ function PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables, $table_
. $target_tables_keys[$table_index][$y] . "' AND TABLE_NAME <> REFERENCED_TABLE_NAME;";
$pk_query_result = PMA_DBI_fetch_result($pk_query, null, null, $trg_link);
- $result_size = sizeof($pk_query_result);
+ $result_size = count($pk_query_result);
if ($result_size > 0) {
for ($b = 0; $b < $result_size; $b++) {
- $drop_pk_query = "DELETE FROM " . PMA_backquote($pk_query_result[$b]['TABLE_SCHEMA']) . "." . PMA_backquote($pk_query_result[$b]['TABLE_NAME']) . " WHERE " . PMA_backquote($pk_query_result[$b]['COLUMN_NAME']) . " = " . $target_tables_keys[$table_index][$y] . ";";
+ $drop_pk_query = "DELETE FROM "
+ . PMA_backquote($pk_query_result[$b]['TABLE_SCHEMA'])
+ . "."
+ . PMA_backquote($pk_query_result[$b]['TABLE_NAME'])
+ . " WHERE "
+ . PMA_backquote($pk_query_result[$b]['COLUMN_NAME'])
+ . " = " . $target_tables_keys[$table_index][$y] . ";";
PMA_DBI_try_query($drop_pk_query, $trg_link, 0);
}
}
@@ -829,6 +916,8 @@ function PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables, $table_
* target table
* @param array &$target_tables_keys field names which is key in the target table
* @param int $matching_table_index number of the matching table
+ *
+ * @return nothing
*/
function PMA_structureDiffInTables($src_db, $trg_db, $src_link, $trg_link,
$matching_tables, &$source_columns, &$target_columns, &$alter_str_array,
@@ -836,12 +925,23 @@ function PMA_structureDiffInTables($src_db, $trg_db, $src_link, $trg_link,
$matching_table_index
) {
//Gets column information for source and target table
- $source_columns[$matching_table_index] = PMA_DBI_get_columns_full($src_db, $matching_tables[$matching_table_index], null, $src_link);
- $target_columns[$matching_table_index] = PMA_DBI_get_columns_full($trg_db, $matching_tables[$matching_table_index], null, $trg_link);
+ $source_columns[$matching_table_index] = PMA_DBI_get_columns_full(
+ $src_db,
+ $matching_tables[$matching_table_index],
+ null,
+ $src_link
+ );
+ $target_columns[$matching_table_index] = PMA_DBI_get_columns_full(
+ $trg_db,
+ $matching_tables[$matching_table_index],
+ null,
+ $trg_link
+ );
foreach ($source_columns[$matching_table_index] as $column_name => $each_column) {
if (isset($target_columns[$matching_table_index][$column_name]['Field'])) {
- //If column exists in target table then matches criteria like type, null, collation, key, default, comment of the column
- for ($i = 0; $i < sizeof($criteria); $i++) {
+ //If column exists in target table then matches criteria like type,
+ // null, collation, key, default, comment of the column
+ for ($i = 0; $i < count($criteria); $i++) {
if ($source_columns[$matching_table_index][$column_name][$criteria[$i]] != $target_columns[$matching_table_index][$column_name][$criteria[$i]]) {
if (($criteria[$i] == 'Default') && ($source_columns[$matching_table_index][$column_name][$criteria[$i]] == '' )) {
$alter_str_array[$matching_table_index][$column_name][$criteria[$i]] = 'None';
@@ -907,7 +1007,7 @@ function PMA_addColumnsInTargetTable($src_db, $trg_db, $src_link, $trg_link,
$criteria, $matching_tables_keys, $target_tables_keys, $uncommon_tables,
&$uncommon_tables_fields, $table_counter, $uncommon_cols, $display
) {
- for ($i = 0; $i < sizeof($matching_tables_fields[$table_counter]); $i++) {
+ for ($i = 0; $i < count($matching_tables_fields[$table_counter]); $i++) {
if (isset($add_column_array[$table_counter][$matching_tables_fields[$table_counter][$i]])) {
$query = "ALTER TABLE " . PMA_backquote($trg_db) . '.' . PMA_backquote($matching_tables[$table_counter]). " ADD COLUMN " .
PMA_backquote($add_column_array[$table_counter][$matching_tables_fields[$table_counter][$i]]) . " " . $source_columns[$table_counter][$matching_tables_fields[$table_counter][$i]]['Type'];
@@ -927,7 +1027,7 @@ function PMA_addColumnsInTargetTable($src_db, $trg_db, $src_link, $trg_link,
$query .= " COMMENT " . $source_columns[$table_counter][$matching_tables_fields[$table_counter][$i]]['Comment'];
}
if ($source_columns[$table_counter][$matching_tables_fields[$table_counter][$i]]['Key'] == 'PRI' ) {
- $trg_key_size = sizeof($target_tables_keys[$table_counter]);
+ $trg_key_size = count($target_tables_keys[$table_counter]);
if ($trg_key_size) {
$check = true;
for ($a = 0; ($a < $trg_key_size) && ($check); $a++) {
@@ -940,9 +1040,9 @@ function PMA_addColumnsInTargetTable($src_db, $trg_db, $src_link, $trg_link,
}
}
$query .= " , ADD PRIMARY KEY (";
- for ($t = 0; $t < sizeof($matching_tables_keys[$table_counter]); $t++) {
+ for ($t = 0; $t < count($matching_tables_keys[$table_counter]); $t++) {
$query .= PMA_backquote($matching_tables_keys[$table_counter][$t]);
- if ($t < (sizeof($matching_tables_keys[$table_counter]) - 1)) {
+ if ($t < (count($matching_tables_keys[$table_counter]) - 1)) {
$query .= " , " ;
}
}
@@ -955,15 +1055,16 @@ function PMA_addColumnsInTargetTable($src_db, $trg_db, $src_link, $trg_link,
}
PMA_DBI_try_query($query, $trg_link, 0);
- //Checks if column to be added is a foreign key or not
+ // Checks if column to be added is a foreign key or not
$is_fk_query = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = '" . $trg_db . "' AND TABLE_NAME = '"
. $matching_tables[$table_counter] . "' AND COLUMN_NAME ='" . $add_column_array[$table_counter][$matching_tables_fields[$table_counter][$i]] .
"' AND TABLE_NAME <> REFERENCED_TABLE_NAME;";
$is_fk_result = PMA_DBI_fetch_result($is_fk_query, null, null, $src_link);
- //If column is a foreign key then it is checked that referenced table exist in target db. If referenced table does not exist in target db then
- //it is created first.
+ // If column is a foreign key then it is checked that referenced table
+ // exist in target db. If referenced table does not exist in target
+ // db then it is created first.
if (isset($is_fk_result)) {
if (in_array($is_fk_result[0]['REFERENCED_TABLE_NAME'], $uncommon_tables)) {
$table_index = array_keys($uncommon_tables, $is_fk_result[0]['REFERENCED_TABLE_NAME']);
@@ -1004,8 +1105,8 @@ function PMA_checkForeignKeys($src_db, $src_link, $trg_db, $trg_link,
AND TABLE_NAME = '" . $referenced_table . "' AND TABLE_NAME <> REFERENCED_TABLE_NAME;";
$is_fk_result = PMA_DBI_fetch_result($is_fk_query, null, null, $src_link);
- if (sizeof($is_fk_result) > 0) {
- for ($j = 0; $j < sizeof($is_fk_result); $j++) {
+ if (count($is_fk_result) > 0) {
+ for ($j = 0; $j < count($is_fk_result); $j++) {
if (in_array($is_fk_result[$j]['REFERENCED_TABLE_NAME'], $uncommon_tables)) {
$table_index = array_keys($uncommon_tables, $is_fk_result[$j]['REFERENCED_TABLE_NAME']);
PMA_checkForeignKeys(
@@ -1029,8 +1130,10 @@ function PMA_checkForeignKeys($src_db, $src_link, $trg_db, $trg_link,
* altered for the targert table
* @param array $matching_tables_fields name of the fields for the matching table
* @param array $criteria criteria
- * @param array &$matching_tables_keys field names which is key in the source table
- * @param array &$target_tables_keys field names which is key in the target table
+ * @param array &$matching_tables_keys field names which is key in the source
+ * table
+ * @param array &$target_tables_keys field names which is key in the target
+ * table
* @param int $matching_table_index number of the matching table
* @param bool $display whether to display query
*
@@ -1045,7 +1148,7 @@ function PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables,
$found = false;
//Checks if the criteria to be altered is primary key
- for ($v = 0; $v < sizeof($matching_tables_fields[$matching_table_index]); $v++) {
+ for ($v = 0; $v < count($matching_tables_fields[$matching_table_index]); $v++) {
if (isset($alter_str_array[$matching_table_index][$matching_tables_fields[$matching_table_index][$v]]['Key'])) {
if ($alter_str_array[$matching_table_index][$matching_tables_fields[$matching_table_index][$v]]['Key'] == 'PRI' ) {
$check = false;
@@ -1056,13 +1159,13 @@ function PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables,
$pri_query = null;
if (! $check) {
$pri_query = "ALTER TABLE " . PMA_backquote($trg_db) . '.' . PMA_backquote($matching_tables[$matching_table_index]);
- if (sizeof($target_tables_keys[$matching_table_index]) > 0) {
+ if (count($target_tables_keys[$matching_table_index]) > 0) {
$pri_query .= " DROP PRIMARY KEY ," ;
}
$pri_query .= " ADD PRIMARY KEY (";
- for ($z = 0; $z < sizeof($matching_tables_keys[$matching_table_index]); $z++) {
+ for ($z = 0; $z < count($matching_tables_keys[$matching_table_index]); $z++) {
$pri_query .= PMA_backquote($matching_tables_keys[$matching_table_index][$z]);
- if ($z < (sizeof($matching_tables_keys[$matching_table_index]) - 1)) {
+ if ($z < (count($matching_tables_keys[$matching_table_index]) - 1)) {
$pri_query .= " , " ;
}
}
@@ -1075,12 +1178,12 @@ function PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables,
}
PMA_DBI_try_query($pri_query, $trg_link, 0);
}
- for ($t = 0; $t < sizeof($matching_tables_fields[$matching_table_index]); $t++) {
- if ((isset($alter_str_array[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]])) && (sizeof($alter_str_array[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]]) > 0)) {
+ for ($t = 0; $t < count($matching_tables_fields[$matching_table_index]); $t++) {
+ if ((isset($alter_str_array[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]])) && (count($alter_str_array[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]]) > 0)) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($trg_db) . '.' . PMA_backquote($matching_tables[$matching_table_index]) . ' MODIFY ' .
PMA_backquote($matching_tables_fields[$matching_table_index][$t]) . ' ' . $source_columns[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]]['Type'];
$found = false;
- for ($i = 0; $i < sizeof($criteria); $i++) {
+ for ($i = 0; $i < count($criteria); $i++) {
if (isset($alter_str_array[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]][$criteria[$i]]) && $criteria[$i] != 'Key') {
$found = true;
if (($criteria[$i] == 'Type') && (! isset($alter_str_array[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]][$criteria[$i+1]]))) {
@@ -1137,13 +1240,14 @@ function PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables,
}
}
$check = false;
- $query = "ALTER TABLE " . PMA_backquote($trg_db) . '.' . PMA_backquote($matching_tables[$matching_table_index]);
- for ($p = 0; $p < sizeof($matching_tables_keys[$matching_table_index]); $p++) {
+ $query = "ALTER TABLE " . PMA_backquote($trg_db) . '.'
+ . PMA_backquote($matching_tables[$matching_table_index]);
+ for ($p = 0; $p < count($matching_tables_keys[$matching_table_index]); $p++) {
if ((isset($alter_str_array[$matching_table_index][$matching_tables_keys[$matching_table_index][$p]]['Key']))) {
$check = true;
$query .= ' MODIFY ' . PMA_backquote($matching_tables_keys[$matching_table_index][$p]) . ' '
. $source_columns[$matching_table_index][$matching_tables_fields[$matching_table_index][$p]]['Type'] . ' Not Null ';
- if ($p < (sizeof($matching_tables_keys[$matching_table_index]) - 1)) {
+ if ($p < (count($matching_tables_keys[$matching_table_index]) - 1)) {
$query .= ', ';
}
}
@@ -1163,8 +1267,10 @@ function PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables,
* @param string $trg_db name of target database
* @param mixed $trg_link connection established with target server
* @param array $matching_tables names of matching tables
- * @param array $uncommon_columns array containing the names of the column which are to be dropped from the target table
- * @param int $table_counter index of the matching table as in $matchiing_tables array
+ * @param array $uncommon_columns array containing the names of the column which
+ * are to be dropped from the target table
+ * @param int $table_counter index of the matching table as in
+ * $matchiing_tables array
* @param bool $display whether to display query
*
* @return nothing
@@ -1173,15 +1279,16 @@ function PMA_removeColumnsFromTargetTable($trg_db, $trg_link, $matching_tables,
$uncommon_columns, $table_counter, $display
) {
if (isset($uncommon_columns[$table_counter])) {
- $drop_query = "ALTER TABLE " . PMA_backquote($trg_db) . "." . PMA_backquote($matching_tables[$table_counter]);
- for ($a = 0; $a < sizeof($uncommon_columns[$table_counter]); $a++) {
+ $drop_query = "ALTER TABLE " . PMA_backquote($trg_db) . "."
+ . PMA_backquote($matching_tables[$table_counter]);
+ for ($a = 0; $a < count($uncommon_columns[$table_counter]); $a++) {
//Checks if column to be removed is a foreign key in any table
$pk_query = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_SCHEMA = '" . $trg_db . "'
AND REFERENCED_TABLE_NAME = '" . $matching_tables[$table_counter]."' AND REFERENCED_COLUMN_NAME = '"
. $uncommon_columns[$table_counter][$a] . "' AND TABLE_NAME <> REFERENCED_TABLE_NAME;";
$pk_query_result = PMA_DBI_fetch_result($pk_query, null, null, $trg_link);
- $result_size = sizeof($pk_query_result);
+ $result_size = count($pk_query_result);
if ($result_size > 0) {
for ($b = 0; $b < $result_size; $b++) {
@@ -1196,11 +1303,11 @@ function PMA_removeColumnsFromTargetTable($trg_db, $trg_link, $matching_tables,
$result = PMA_DBI_fetch_result($query, null, null, $trg_link);
- if (sizeof($result) > 0) {
+ if (count($result) > 0) {
$drop_query .= " DROP FOREIGN KEY " . PMA_backquote($result[0]['CONSTRAINT_NAME']) . ",";
}
$drop_query .= " DROP COLUMN " . PMA_backquote($uncommon_columns[$table_counter][$a]);
- if ($a < (sizeof($uncommon_columns[$table_counter]) - 1)) {
+ if ($a < (count($uncommon_columns[$table_counter]) - 1)) {
$drop_query .= " , " ;
}
}
@@ -1214,9 +1321,11 @@ function PMA_removeColumnsFromTargetTable($trg_db, $trg_link, $matching_tables,
}
/**
- * PMA_indexesDiffInTables() compares the source table indexes with target table indexes and keep the indexes to be added in target table in $add_indexes_array
- * indexes to be altered in $alter_indexes_array and indexes to be removed from target table in $remove_indexes_array.
- * Only keyname and uniqueness characteristic of the indexes are altered.
+ * PMA_indexesDiffInTables() compares the source table indexes with target
+ * table indexes and keep the indexes to be added in target table in
+ * $add_indexes_array indexes to be altered in $alter_indexes_array and indexes
+ * to be removed from target table in $remove_indexes_array. Only keyname and
+ * uniqueness characteristic of the indexes are altered.
*
* @param string $src_db name of source database
* @param string $trg_db name of target database
@@ -1241,14 +1350,14 @@ function PMA_indexesDiffInTables($src_db, $trg_db, $src_link, $trg_link,
//Gets indexes information for source and target table
$source_indexes[$table_counter] = PMA_DBI_get_table_indexes($src_db, $matching_tables[$table_counter], $src_link);
$target_indexes[$table_counter] = PMA_DBI_get_table_indexes($trg_db, $matching_tables[$table_counter], $trg_link);
- for ($a = 0; $a < sizeof($source_indexes[$table_counter]); $a++) {
+ for ($a = 0; $a < count($source_indexes[$table_counter]); $a++) {
$found = false;
$z = 0;
//Compares key name and non_unique characteristic of source indexes with target indexes
/*
* @todo compare the length of each sub part
*/
- while (($z <= sizeof($target_indexes[$table_counter])) && ($found == false)) {
+ while (($z <= count($target_indexes[$table_counter])) && ($found == false)) {
if (isset($source_indexes[$table_counter][$a]) && isset($target_indexes[$table_counter][$z]) && $source_indexes[$table_counter][$a]['Key_name'] == $target_indexes[$table_counter][$z]['Key_name']) {
$found = true;
if (($source_indexes[$table_counter][$a]['Column_name'] != $target_indexes[$table_counter][$z]['Column_name']) || ($source_indexes[$table_counter][$a]['Non_unique'] != $target_indexes[$table_counter][$z]['Non_unique'])) {
@@ -1267,10 +1376,10 @@ function PMA_indexesDiffInTables($src_db, $trg_db, $src_link, $trg_link,
}
//Finds indexes that exist on target table but not on source table
- for ($b = 0; $b < sizeof($target_indexes[$table_counter]); $b++) {
+ for ($b = 0; $b < count($target_indexes[$table_counter]); $b++) {
$found = false;
$c = 0;
- while (($c <= sizeof($source_indexes[$table_counter])) && ($found == false)) {
+ while (($c <= count($source_indexes[$table_counter])) && ($found == false)) {
if ($target_indexes[$table_counter][$b]['Column_name'] == $source_indexes[$table_counter][$c]['Column_name']) {
$found = true;
}
@@ -1290,9 +1399,12 @@ function PMA_indexesDiffInTables($src_db, $trg_db, $src_link, $trg_link,
* @param array $matching_tables matching tables name
* @param array $source_indexes indexes of the source table
* @param array $target_indexes indexes of the target table
- * @param array $add_indexes_array column names on which indexes are to be created in target table
- * @param array $alter_indexes_array column names for which indexes are to be altered
- * @param array $remove_indexes_array key name of the indexes which are to be removed from the target table
+ * @param array $add_indexes_array column names on which indexes are to be
+ * created in target table
+ * @param array $alter_indexes_array column names for which indexes are to be
+ * altered
+ * @param array $remove_indexes_array key name of the indexes which are to be
+ * removed from the target table
* @param int $table_counter number of the matching table
* @param bool $display whether to display query
*
@@ -1305,9 +1417,9 @@ function PMA_applyIndexesDiff($trg_db, $trg_link, $matching_tables, $source_inde
//Adds indexes on target table
if (isset($add_indexes_array[$table_counter])) {
$sql = "ALTER TABLE " . PMA_backquote($trg_db) . "." . PMA_backquote($matching_tables[$table_counter]) . " ADD" ;
- for ($a = 0; $a < sizeof($source_indexes[$table_counter]); $a++) {
+ for ($a = 0; $a < count($source_indexes[$table_counter]); $a++) {
if (isset($add_indexes_array[$table_counter][$a])) {
- for ($b = 0; $b < sizeof($source_indexes[$table_counter]); $b++) {
+ for ($b = 0; $b < count($source_indexes[$table_counter]); $b++) {
if ($source_indexes[$table_counter][$b]['Column_name'] == $add_indexes_array[$table_counter][$a]) {
if ($source_indexes[$table_counter][$b]['Non_unique'] == '0') {
$sql .= " UNIQUE ";
@@ -1326,11 +1438,11 @@ function PMA_applyIndexesDiff($trg_db, $trg_link, $matching_tables, $source_inde
if (isset($alter_indexes_array[$table_counter])) {
$query = "ALTER TABLE " . PMA_backquote($trg_db) . "." . PMA_backquote($matching_tables[$table_counter]);
- for ($a = 0; $a < sizeof($alter_indexes_array[$table_counter]); $a++) {
+ for ($a = 0; $a < count($alter_indexes_array[$table_counter]); $a++) {
if (isset($alter_indexes_array[$table_counter][$a])) {
$query .= ' DROP INDEX ' . PMA_backquote($alter_indexes_array[$table_counter][$a]) . " , ADD ";
$got_first_index_column = false;
- for ($z = 0; $z < sizeof($source_indexes[$table_counter]); $z++) {
+ for ($z = 0; $z < count($source_indexes[$table_counter]); $z++) {
if ($source_indexes[$table_counter][$z]['Key_name'] == $alter_indexes_array[$table_counter][$a]) {
if (! $got_first_index_column) {
if ($source_indexes[$table_counter][$z]['Non_unique'] == '0') {
@@ -1356,11 +1468,11 @@ function PMA_applyIndexesDiff($trg_db, $trg_link, $matching_tables, $source_inde
//Removes indexes from target table
if (isset($remove_indexes_array[$table_counter])) {
$drop_index_query = "ALTER TABLE " . PMA_backquote($trg_db) . "." . PMA_backquote($matching_tables[$table_counter]);
- for ($a = 0; $a < sizeof($target_indexes[$table_counter]); $a++) {
+ for ($a = 0; $a < count($target_indexes[$table_counter]); $a++) {
if (isset($remove_indexes_array[$table_counter][$a])) {
$drop_index_query .= " DROP INDEX " . PMA_backquote($remove_indexes_array[$table_counter][$a]);
}
- if ($a < (sizeof($remove_indexes_array[$table_counter]) - 1)) {
+ if ($a < (count($remove_indexes_array[$table_counter]) - 1)) {
$drop_index_query .= " , " ;
}
}
@@ -1402,19 +1514,23 @@ function PMA_syncDisplayHeaderCompare($src_db, $trg_db)
echo '';
echo '';
- echo '' . __('Source database') . ': ' . htmlspecialchars($src_db) . ' (';
+ echo ' | ' . __('Source database') . ': '
+ . htmlspecialchars($src_db) . ' (';
if ('cur' == $_SESSION['src_type']) {
echo __('Current server');
} else {
- echo __('Remote server') . ' ' . htmlspecialchars($_SESSION['src_server']['host']);
+ echo __('Remote server') . ' '
+ . htmlspecialchars($_SESSION['src_server']['host']);
}
echo ') | ';
echo '' . __('Difference') . ' | ';
- echo '' . __('Target database') . ': '. htmlspecialchars($trg_db) . ' (';
+ echo ' | ' . __('Target database') . ': '
+ . htmlspecialchars($trg_db) . ' (';
if ('cur' == $_SESSION['trg_type']) {
echo __('Current server');
} else {
- echo __('Remote server') . ' ' . htmlspecialchars($_SESSION['trg_server']['host']);
+ echo __('Remote server') . ' '
+ . htmlspecialchars($_SESSION['trg_server']['host']);
}
echo ') | ';
echo '
';
@@ -1479,9 +1595,9 @@ function PMA_syncDisplayDataCompare($rows)
function PMA_getColumnValues($database, $table, $column, $link = null)
{
$query = 'SELECT ';
- for ($i=0; $i< sizeof($column); $i++) {
+ for ($i = 0; $i < count($column); $i++) {
$query.= PMA_backquote($column[$i]);
- if ($i < (sizeof($column)-1)) {
+ if ($i < (count($column)-1)) {
$query.= ', ';
}
}
diff --git a/libraries/tbl_properties.inc.php b/libraries/tbl_properties.inc.php
index 525f4a4b4a..dadf08f4c5 100644
--- a/libraries/tbl_properties.inc.php
+++ b/libraries/tbl_properties.inc.php
@@ -639,16 +639,12 @@ for ($i = 0; $i < $num_fields; $i++) {
. '">';
if (is_array($available_mime['transformation'])) {
foreach ($available_mime['transformation'] as $mimekey => $transform) {
- $match = preg_match(
- '@' . preg_quote(
- $available_mime['transformation_file'][$mimekey]
- )
- . '3?@i',
- $mime_map[$row['Field']]['transformation']
- );
$checked = isset($row['Field'])
&& isset($mime_map[$row['Field']]['transformation'])
- && $match
+ && preg_match(
+ '@' . preg_quote($available_mime['transformation_file'][$mimekey]) . '3?@i',
+ $mime_map[$row['Field']]['transformation']
+ )
? 'selected '
: '';
$tooltip = PMA_getTransformationDescription(
diff --git a/main.php b/main.php
index 9dc61bdf67..202eb86627 100644
--- a/main.php
+++ b/main.php
@@ -19,7 +19,7 @@ if ($GLOBALS['PMA_Config']->isGitRevision()) {
if (isset($_REQUEST['git_revision']) && $GLOBALS['is_ajax_request'] == true) {
PMA_printGitRevision();
}
- PMA_AddJSVar('is_git_revision', true);
+ PMA_addJSVar('is_git_revision', true);
}
// Handles some variables that may have been sent by the calling script
diff --git a/pmd_general.php b/pmd_general.php
index f9a8c45948..bdc52f376d 100644
--- a/pmd_general.php
+++ b/pmd_general.php
@@ -79,64 +79,64 @@ echo $script_tabs . $script_contr . $script_display_field;
+ alt="v" src="getImgPath('pmd/downarrow2_m.png'); ?>" />


; ?>)

; ?>)

; ?>)

; ?>)


; ?>)
; ?>)



; ?>)
; ?>)
-
+
-
+
-
+

';
- echo '
getImgPath('pmd/query_builder.png') . '" alt="key" width="20" height="20" title="';
echo __('Build Query');
echo '"/>';
}
?>
-
@@ -149,11 +149,11 @@ if (isset($_REQUEST['query'])) {
+ src="getImgPath('pmd/downarrow1.png'); ?>" id='key_HS_all' />
+ src="getImgPath('pmd/downarrow2.png'); ?>" id='key_HS' />