diff --git a/ChangeLog b/ChangeLog index 699cc1df4b..0cdaad4722 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,9 @@ phpMyAdmin - ChangeLog 4.1.0.0 (not yet released) +4.0.1.0 (not yet released) +- bug #3879 Import broken for CSV using LOAD DATA + 4.0.0.0 (not yet released) + Patch #3481047 for rfe #3480477 Insert as new row enhancement + Patch #3480999 Activate codemirror in the query window diff --git a/import.php b/import.php index 78f238730c..09272e7231 100644 --- a/import.php +++ b/import.php @@ -474,7 +474,8 @@ if (! $error) { $import_plugin = PMA_getPlugin( "import", $format, - 'libraries/plugins/import/' + 'libraries/plugins/import/', + $import_type ); if ($import_plugin == null) { $error = true; diff --git a/libraries/plugins/import/AbstractImportCsv.class.php b/libraries/plugins/import/AbstractImportCsv.class.php new file mode 100644 index 0000000000..62ca8bb541 --- /dev/null +++ b/libraries/plugins/import/AbstractImportCsv.class.php @@ -0,0 +1,91 @@ +setOptionsText(__('Options')); + + // create the root group that will be the options field for + // $importPluginProperties + // this will be shown as "Format specific options" + $importSpecificOptions = new OptionsPropertyRootGroup(); + $importSpecificOptions->setName("Format Specific Options"); + + // general options main group + $generalOptions = new OptionsPropertyMainGroup(); + $generalOptions->setName("general_opts"); + + // create common items and add them to the group + $leaf = new BoolPropertyItem(); + $leaf->setName("replace"); + $leaf->setText(__('Replace table data with file')); + $generalOptions->addProperty($leaf); + $leaf = new TextPropertyItem(); + $leaf->setName("terminated"); + $leaf->setText(__('Columns separated with:')); + $leaf->setSize(2); + $leaf->setLen(2); + $generalOptions->addProperty($leaf); + $leaf = new TextPropertyItem(); + $leaf->setName("enclosed"); + $leaf->setText(__('Columns enclosed with:')); + $leaf->setSize(2); + $leaf->setLen(2); + $generalOptions->addProperty($leaf); + $leaf = new TextPropertyItem(); + $leaf->setName("escaped"); + $leaf->setText(__('Columns escaped with:')); + $leaf->setSize(2); + $leaf->setLen(2); + $generalOptions->addProperty($leaf); + $leaf = new TextPropertyItem(); + $leaf->setName("new_line"); + $leaf->setText(__('Lines terminated with:')); + $leaf->setSize(2); + $generalOptions->addProperty($leaf); + + // add the main group to the root group + $importSpecificOptions->addProperty($generalOptions); + + // set the options for the import plugin property item + $importPluginProperties->setOptions($importSpecificOptions); + $this->properties = $importPluginProperties; + + return $generalOptions; + } +} +?> \ No newline at end of file diff --git a/libraries/plugins/import/ImportCsv.class.php b/libraries/plugins/import/ImportCsv.class.php index b6aa3894a9..3ee68c9310 100644 --- a/libraries/plugins/import/ImportCsv.class.php +++ b/libraries/plugins/import/ImportCsv.class.php @@ -12,7 +12,7 @@ if (! defined('PHPMYADMIN')) { } /* Get the import interface */ -require_once 'libraries/plugins/ImportPlugin.class.php'; +require_once 'libraries/plugins/import/AbstractImportCsv.class.php'; /** * Handles the import for the CSV format @@ -20,7 +20,7 @@ require_once 'libraries/plugins/ImportPlugin.class.php'; * @package PhpMyAdmin-Import * @subpackage CSV */ -class ImportCsv extends ImportPlugin +class ImportCsv extends AbstractImportCsv { /** * Whether to analyze tables @@ -51,55 +51,9 @@ class ImportCsv extends ImportPlugin $this->_setAnalyze(true); } - $props = 'libraries/properties/'; - include_once "$props/plugins/ImportPluginProperties.class.php"; - include_once "$props/options/groups/OptionsPropertyRootGroup.class.php"; - include_once "$props/options/groups/OptionsPropertyMainGroup.class.php"; - include_once "$props/options/items/BoolPropertyItem.class.php"; - include_once "$props/options/items/TextPropertyItem.class.php"; - - $importPluginProperties = new ImportPluginProperties(); - $importPluginProperties->setText('CSV'); - $importPluginProperties->setExtension('csv'); - $importPluginProperties->setOptionsText(__('Options')); - - // create the root group that will be the options field for - // $importPluginProperties - // this will be shown as "Format specific options" - $importSpecificOptions = new OptionsPropertyRootGroup(); - $importSpecificOptions->setName("Format Specific Options"); - - // general options main group - $generalOptions = new OptionsPropertyMainGroup(); - $generalOptions->setName("general_opts"); - // create primary items and add them to the group - $leaf = new BoolPropertyItem(); - $leaf->setName("replace"); - $leaf->setText(__('Replace table data with file')); - $generalOptions->addProperty($leaf); - $leaf = new TextPropertyItem(); - $leaf->setName("terminated"); - $leaf->setText(__('Columns separated with:')); - $leaf->setSize(2); - $leaf->setLen(2); - $generalOptions->addProperty($leaf); - $leaf = new TextPropertyItem(); - $leaf->setName("enclosed"); - $leaf->setText(__('Columns enclosed with:')); - $leaf->setSize(2); - $leaf->setLen(2); - $generalOptions->addProperty($leaf); - $leaf = new TextPropertyItem(); - $leaf->setName("escaped"); - $leaf->setText(__('Columns escaped with:')); - $leaf->setSize(2); - $leaf->setLen(2); - $generalOptions->addProperty($leaf); - $leaf = new TextPropertyItem(); - $leaf->setName("new_line"); - $leaf->setText(__('Lines terminated with:')); - $leaf->setSize(2); - $generalOptions->addProperty($leaf); + $generalOptions = parent::setProperties(); + $this->properties->setText('CSV'); + $this->properties->setExtension('csv'); if ($GLOBALS['plugin_param'] !== 'table') { $leaf = new BoolPropertyItem(); @@ -129,13 +83,6 @@ class ImportCsv extends ImportPlugin ); $generalOptions->addProperty($leaf); } - - // add the main group to the root group - $importSpecificOptions->addProperty($generalOptions); - - // set the options for the import plugin property item - $importPluginProperties->setOptions($importSpecificOptions); - $this->properties = $importPluginProperties; } /** @@ -158,7 +105,7 @@ class ImportCsv extends ImportPlugin */ public function doImport() { - global $db, $csv_terminated, $csv_enclosed, $csv_escaped, $csv_new_line; + global $db, $table, $csv_terminated, $csv_enclosed, $csv_escaped, $csv_new_line; global $error, $timeout_passed, $finished; $replacements = array( diff --git a/libraries/plugins/import/ImportLdi.class.php b/libraries/plugins/import/ImportLdi.class.php index b38e74b052..8d375e63ac 100644 --- a/libraries/plugins/import/ImportLdi.class.php +++ b/libraries/plugins/import/ImportLdi.class.php @@ -11,7 +11,7 @@ if (! defined('PHPMYADMIN')) { } /* Get the import interface */ -require_once 'libraries/plugins/ImportPlugin.class.php'; +require_once 'libraries/plugins/import/AbstractImportCsv.class.php'; // We need relations enabled and we work only on database if ($GLOBALS['plugin_param'] !== 'table') { @@ -25,7 +25,7 @@ if ($GLOBALS['plugin_param'] !== 'table') { * @package PhpMyAdmin-Import * @subpackage LDI */ -class ImportLdi extends ImportPlugin +class ImportLdi extends AbstractImportCsv { /** * Constructor @@ -57,39 +57,24 @@ class ImportLdi extends ImportPlugin unset($result); } - $props = 'libraries/properties/'; - include_once "$props/plugins/ImportPluginProperties.class.php"; - include_once "$props/options/groups/OptionsPropertyRootGroup.class.php"; - include_once "$props/options/groups/OptionsPropertyMainGroup.class.php"; - include_once "$props/options/items/BoolPropertyItem.class.php"; - include_once "$props/options/items/TextPropertyItem.class.php"; + $generalOptions = parent::setProperties(); + $this->properties->setText('CSV using LOAD DATA'); + $this->properties->setExtension('ldi'); - $importPluginProperties = new ImportPluginProperties(); - $importPluginProperties->setText('CSV using LOAD DATA'); - $importPluginProperties->setExtension('ldi'); - $importPluginProperties->setOptionsText(__('Options')); - - // create the root group that will be the options field for - // $importPluginProperties - // this will be shown as "Format specific options" - $importSpecificOptions = new OptionsPropertyRootGroup(); - $importSpecificOptions->setName("Format Specific Options"); - - // general options main group - $generalOptions = new OptionsPropertyMainGroup(); - $generalOptions->setName("general_opts"); - // create primary items and add them to the group - $leaf = new BoolPropertyItem(); - $leaf->setName("replace"); - $leaf->setText(__('Replace table data with file')); + $leaf = new TextPropertyItem(); + $leaf->setName("columns"); + $leaf->setText(__('Column names: ')); $generalOptions->addProperty($leaf); - // add the main group to the root group - $importSpecificOptions->addProperty($generalOptions); + $leaf = new BoolPropertyItem(); + $leaf->setName("ignore"); + $leaf->setText(__('Do not abort on INSERT error')); + $generalOptions->addProperty($leaf); - // set the options for the import plugin property item - $importPluginProperties->setOptions($importSpecificOptions); - $this->properties = $importPluginProperties; + $leaf = new BoolPropertyItem(); + $leaf->setName("local_option"); + $leaf->setText(__('Use LOCAL keyword')); + $generalOptions->addProperty($leaf); } /** @@ -112,7 +97,7 @@ class ImportLdi extends ImportPlugin */ public function doImport() { - global $finished, $error, $import_file, $compression, $charset_conversion; + global $finished, $error, $import_file, $compression, $charset_conversion, $table; global $ldi_local_option, $ldi_replace, $ldi_terminated, $ldi_enclosed, $ldi_escaped, $ldi_new_line, $skip_queries, $ldi_columns;