isMerge() public method

If the ENGINE of the table is MERGE or MRG_MYISAM (alias), this is a merge table.
public isMerge ( ) : boolean
return boolean true if it is a merge table
Example #1
0
/**
 * Prints Html For Export Options
 *
 * @param String         $export_type    Selected Export Type
 * @param String         $db             Selected DB
 * @param String         $table          Selected Table
 * @param String         $multi_values   Export selection
 * @param String         $num_tables     number of tables
 * @param ExportPlugin[] $export_list    Export List
 * @param String         $unlim_num_rows Number of Rows
 *
 * @return string
 */
function PMA_getHtmlForExportOptions($export_type, $db, $table, $multi_values, $num_tables, $export_list, $unlim_num_rows)
{
    global $cfg;
    $html = PMA_getHtmlForExportOptionsMethod();
    $html .= PMA_getHtmlForExportOptionsFormatDropdown($export_list);
    $html .= PMA_getHtmlForExportOptionsSelection($export_type, $multi_values);
    $_table = new Table($table, $db);
    if (strlen($table) > 0 && empty($num_tables) && !$_table->isMerge()) {
        $html .= PMA_getHtmlForExportOptionsRows($db, $table, $unlim_num_rows);
    }
    if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) {
        $html .= PMA_getHtmlForExportOptionsQuickExport();
    }
    $html .= PMA_getHtmlForAliasModalDialog($db, $table);
    $html .= PMA_getHtmlForExportOptionsOutput($export_type);
    $html .= PMA_getHtmlForExportOptionsFormat($export_list);
    return $html;
}
Example #2
0
 /**
  * Test for isMerge -- when ENGINE info is ISDB
  *
  * @return void
  */
 public function testIsMergeCase4()
 {
     $map = array(array(array('PMA', 'PMA_BookMark'), null, array('ENGINE' => "ISDB")), array(array('PMA', 'PMA_BookMark', 'ENGINE'), null, "ISDB"));
     $GLOBALS['dbi']->expects($this->any())->method('getCachedTableContent')->will($this->returnValueMap($map));
     $tableObj = new Table('PMA_BookMark', 'PMA');
     $this->assertEquals(false, $tableObj->isMerge());
 }
Example #3
0
/**
 * Export at the database level
 *
 * @param string       $db              the database to export
 * @param array        $tables          the tables to export
 * @param string       $whatStrucOrData structure or data or both
 * @param array        $table_structure whether to export structure for each table
 * @param array        $table_data      whether to export data for each table
 * @param ExportPlugin $export_plugin   the selected export plugin
 * @param string       $crlf            end of line character(s)
 * @param string       $err_url         the URL in case of error
 * @param string       $export_type     the export type
 * @param bool         $do_relation     whether to export relation info
 * @param bool         $do_comments     whether to add comments
 * @param bool         $do_mime         whether to add MIME info
 * @param bool         $do_dates        whether to add dates
 * @param array        $aliases         Alias information for db/table/column
 * @param string       $separate_files  whether it is a separate-files export
 *
 * @return void
 */
function PMA_exportDatabase($db, $tables, $whatStrucOrData, $table_structure, $table_data, $export_plugin, $crlf, $err_url, $export_type, $do_relation, $do_comments, $do_mime, $do_dates, $aliases, $separate_files)
{
    $db_alias = !empty($aliases[$db]['alias']) ? $aliases[$db]['alias'] : '';
    if (!$export_plugin->exportDBHeader($db, $db_alias)) {
        return;
    }
    if (!$export_plugin->exportDBCreate($db, $export_type, $db_alias)) {
        return;
    }
    if ($separate_files == 'database') {
        PMA_saveObjectInBuffer('database', true);
    }
    if (($GLOBALS['sql_structure_or_data'] == 'structure' || $GLOBALS['sql_structure_or_data'] == 'structure_and_data') && isset($GLOBALS['sql_procedure_function'])) {
        $export_plugin->exportRoutines($db, $aliases);
        if ($separate_files == 'database') {
            PMA_saveObjectInBuffer('routines');
        }
    }
    $views = array();
    foreach ($tables as $table) {
        $_table = new Table($table, $db);
        // if this is a view, collect it for later;
        // views must be exported after the tables
        $is_view = $_table->isView();
        if ($is_view) {
            $views[] = $table;
        }
        if (($whatStrucOrData == 'structure' || $whatStrucOrData == 'structure_and_data') && in_array($table, $table_structure)) {
            // for a view, export a stand-in definition of the table
            // to resolve view dependencies (only when it's a single-file export)
            if ($is_view) {
                if ($separate_files == '' && isset($GLOBALS['sql_create_view']) && !$export_plugin->exportStructure($db, $table, $crlf, $err_url, 'stand_in', $export_type, $do_relation, $do_comments, $do_mime, $do_dates, $aliases)) {
                    break;
                }
            } else {
                if (isset($GLOBALS['sql_create_table'])) {
                    $table_size = $GLOBALS['maxsize'];
                    // Checking if the maximum table size constrain has been set
                    // And if that constrain is a valid number or not
                    if ($table_size !== '' && is_numeric($table_size)) {
                        // This obtains the current table's size
                        $query = 'SELECT data_length + index_length
                          from information_schema.TABLES
                          WHERE table_schema = "' . $db . '"
                          AND table_name = "' . $table . '"';
                        $size = $GLOBALS['dbi']->fetchValue($query);
                        //Converting the size to MB
                        $size = $size / 1024 / 1024;
                        if ($size > $table_size) {
                            continue;
                        }
                    }
                    if (!$export_plugin->exportStructure($db, $table, $crlf, $err_url, 'create_table', $export_type, $do_relation, $do_comments, $do_mime, $do_dates, $aliases)) {
                        break;
                    }
                }
            }
        }
        // if this is a view or a merge table, don't export data
        if (($whatStrucOrData == 'data' || $whatStrucOrData == 'structure_and_data') && in_array($table, $table_data) && !($is_view || $_table->isMerge())) {
            $local_query = 'SELECT * FROM ' . PMA\libraries\Util::backquote($db) . '.' . PMA\libraries\Util::backquote($table);
            if (!$export_plugin->exportData($db, $table, $crlf, $err_url, $local_query, $aliases)) {
                break;
            }
        }
        // this buffer was filled, we save it and go to the next one
        if ($separate_files == 'database') {
            PMA_saveObjectInBuffer('table_' . $table);
        }
        // now export the triggers (needs to be done after the data because
        // triggers can modify already imported tables)
        if (isset($GLOBALS['sql_create_trigger']) && ($whatStrucOrData == 'structure' || $whatStrucOrData == 'structure_and_data') && in_array($table, $table_structure)) {
            if (!$export_plugin->exportStructure($db, $table, $crlf, $err_url, 'triggers', $export_type, $do_relation, $do_comments, $do_mime, $do_dates, $aliases)) {
                break;
            }
            if ($separate_files == 'database') {
                PMA_saveObjectInBuffer('table_' . $table, true);
            }
        }
    }
    if (isset($GLOBALS['sql_create_view'])) {
        foreach ($views as $view) {
            // no data export for a view
            if ($whatStrucOrData == 'structure' || $whatStrucOrData == 'structure_and_data') {
                if (!$export_plugin->exportStructure($db, $view, $crlf, $err_url, 'create_view', $export_type, $do_relation, $do_comments, $do_mime, $do_dates, $aliases)) {
                    break;
                }
                if ($separate_files == 'database') {
                    PMA_saveObjectInBuffer('view_' . $view);
                }
            }
        }
    }
    if (!$export_plugin->exportDBFooter($db)) {
        return;
    }
    // export metadata related to this db
    if (isset($GLOBALS['sql_metadata'])) {
        // Types of metadata to export.
        // In the future these can be allowed to be selected by the user
        $metadataTypes = PMA_getMetadataTypesToExport();
        $export_plugin->exportMetadata($db, $tables, $metadataTypes);
        if ($separate_files == 'database') {
            PMA_saveObjectInBuffer('metadata');
        }
    }
    if ($separate_files == 'database') {
        PMA_saveObjectInBuffer('extra');
    }
    if (($GLOBALS['sql_structure_or_data'] == 'structure' || $GLOBALS['sql_structure_or_data'] == 'structure_and_data') && isset($GLOBALS['sql_procedure_function'])) {
        $export_plugin->exportEvents($db);
        if ($separate_files == 'database') {
            PMA_saveObjectInBuffer('events');
        }
    }
}