Menu

#2744 Support PHP array in grid export

Fixed
nobody
None
Default
Enhancement
2012-03-06
2012-02-27
Anonymous
No

Originally created by: geki...@gmail.com

It would be nice to have support for more export formats (in the "export grid row" dialog)

The format i really would like to have (and need) is "as php array".
phpmyadmin supports also lot more other ones.

Discussion

  • Anonymous

    Anonymous - 2012-02-27

    Originally posted by: a...@anse.de

    Please explain exactly how your proposed export formats look like. Then we'll decide which of them are reasonable for HeidiSQL.

    Status: NeedInfo

     
  • Anonymous

    Anonymous - 2012-02-27

    Originally posted by: geki...@gmail.com

    hope this example helps:

    sql inserts for the table:

    INSERT INTO `countries` (`id`, `iso3166_alpha2`, `iso3166_alpha3`, `iso3166_numeric`, `iso3166_status`, `iso3166_2`, `unlocode`, `tld`, `postal`, `e164`, `carplate`, `ioc`, `fifa`, `country_short_german`, `country_full_german`, `country_short_english`, `country_full_english`, `country_short_french`, `remark`) VALUES (1, 'AF', 'AFG', 4, 'officially assigned', 'AF', 'AF', '.af', 'AFG', NULL, 'AFG', 'AFG', 'AFG', 'Afghanistan', 'Afghanistan', 'AFGHANISTAN', NULL, 'AFGHANISTAN', NULL);
    INSERT INTO `countries` (`id`, `iso3166_alpha2`, `iso3166_alpha3`, `iso3166_numeric`, `iso3166_status`, `iso3166_2`, `unlocode`, `tld`, `postal`, `e164`, `carplate`, `ioc`, `fifa`, `country_short_german`, `country_full_german`, `country_short_english`, `country_full_english`, `country_short_french`, `remark`) VALUES (2, 'EG', 'EGY', 818, 'officially assigned', 'EG', 'EG', '.eg', 'ET', 20, 'ET', 'EGY', 'EGY', 'Ägypten', 'Ägypten', 'EGYPT', NULL, 'ÉGYPTE', NULL);

    EXPORT OUTPUT:

    $countries = array(
      array('id'=>1,'iso3166_alpha2'=>'AF','iso3166_alpha3'=>'AFG','iso3166_numeric'=>4,'iso3166_status'=>'officially assigned','iso3166_2'=>'AF','unlocode'=>'AF','tld'=>'.af','postal'=>'AFG','e164'=>null,'carplate'=>'AFG','ioc'=>'AFG','fifa'=>'AFG','country_short_german'=>'Afghanistan','country_full_german'=>'Afghanistan','country_short_english'=>'AFGHANISTAN','country_full_english'=>null,'country_short_french'=>'AFGHANISTAN','remark'=>null),
      array('id'=>2,'iso3166_alpha2'=>'EG','iso3166_alpha3'=>'EGY','iso3166_numeric'=>818,'iso3166_status'=>'officially assigned','iso3166_2'=>'EG','unlocode'=>'EG','tld'=>'.eg','postal'=>'ET','e164'=>20,'carplate'=>'ET','ioc'=>'EGY','fifa'=>'EGY','country_short_german'=>'Ägypten','country_full_german'=>'Ägypten','country_short_english'=>'EGYPT','country_full_english'=>null,'country_short_french'=>'ÉGYPTE','remark'=>null),
    );

     
  • Anonymous

    Anonymous - 2012-02-27

    Originally posted by: geki...@gmail.com

    format could be like this:

    $[TABLE_NAME] = array(
    [TAB]array(
    [TAB][TAB][TAB]'[SELECTED_ROW_1_COLUM_1_NAME]' => '[SELECTED_ROW_1_COLUMN_1_VALUE]',
    [TAB][TAB][TAB]'[SELECTED_ROW_1_COLUM_2_NAME]' => '[SELECTED_ROW_1_COLUMN_2_VALUE]',
    [TAB][TAB][TAB]'[SELECTED_ROW_1_COLUM_3_NAME]' => '[SELECTED_ROW_1_COLUMN_3_VALUE]'
    [TAB]),
    [TAB]array(
    [TAB][TAB][TAB]'[SELECTED_ROW_2_COLUM_1_NAME]' => '[SELECTED_ROW_2_COLUMN_1_VALUE]',
    [TAB][TAB][TAB]'[SELECTED_ROW_2_COLUM_2_NAME]' => '[SELECTED_ROW_2_COLUMN_2_VALUE]',
    [TAB][TAB][TAB]'[SELECTED_ROW_2_COLUM_3_NAME]' => '[SELECTED_ROW_2_COLUMN_3_VALUE]'
    [TAB]),
    [TAB]array(
    [TAB][TAB][TAB]'[SELECTED_ROW_3_COLUM_1_NAME]' => '[SELECTED_ROW_3_COLUMN_1_VALUE],
    [TAB][TAB][TAB]'[SELECTED_ROW_3_COLUM_2_NAME]' => '[SELECTED_ROW_3_COLUMN_2_VALUE],
    [TAB][TAB][TAB]'[SELECTED_ROW_3_COLUM_3_NAME]' => '[SELECTED_ROW_3_COLUMN_3_VALUE]
    [TAB])
    );

     
  • Anonymous

    Anonymous - 2012-02-27

    Originally posted by: a...@anse.de

    (No comment was entered for this change.)

    Summary: Support PHP array in grid export
    Status: Accepted

     
  • Anonymous

    Anonymous - 2012-02-28

    Originally posted by: geki...@gmail.com

    if there are more rows selected, i think it would be better to use this format
    if it's difficult to use 2 formats i would say use this one (it's also more like the phpmyadmin one)

    $[TABLE_NAME] = array(
    [TAB]array('[SELECTED_ROW_1_COLUM_1_NAME]' => '[SELECTED_ROW_1_COLUMN_1_VALUE]', '[SELECTED_ROW_1_COLUM_2_NAME]' => '[SELECTED_ROW_1_COLUMN_2_VALUE]', '[SELECTED_ROW_1_COLUM_3_NAME]' => '[SELECTED_ROW_1_COLUMN_3_VALUE]'),
    [TAB]array('[SELECTED_ROW_2_COLUM_1_NAME]' => '[SELECTED_ROW_2_COLUMN_1_VALUE]', '[SELECTED_ROW_2_COLUM_2_NAME]' => '[SELECTED_ROW_2_COLUMN_2_VALUE]', '[SELECTED_ROW_2_COLUM_3_NAME]' => '[SELECTED_ROW_2_COLUMN_3_VALUE]'),
    [TAB]array('[SELECTED_ROW_3_COLUM_1_NAME]' => '[SELECTED_ROW_3_COLUMN_1_VALUE], '[SELECTED_ROW_3_COLUM_2_NAME]' => '[SELECTED_ROW_3_COLUMN_2_VALUE], '[SELECTED_ROW_3_COLUM_3_NAME]' => '[SELECTED_ROW_3_COLUMN_3_VALUE])
    );

     
  • Anonymous

    Anonymous - 2012-02-28

    Originally posted by: a...@anse.de

    Apart from missing tabs I see no difference between comment #3 and comment #5.

     
  • Anonymous

    Anonymous - 2012-02-28

    Originally posted by: geki...@gmail.com

    yes the tabs and the missing new lines before this tabs

    the missing new lines are also the "important" thing:
    you will get a lot less lines (but longer ones)

     
  • Anonymous

    Anonymous - 2012-03-03

    Originally posted by: a...@anse.de

    Done. However, for optical reasons I put every value on its own line, so it takes slightly more space than your proposal above, but I find that more readable. Additionally, I added a comment behind the row start: "array( // row #X", so that probably helps a bit for large datasets.
    Please test.

     
  • Anonymous

    Anonymous - 2012-03-05

    Originally posted by: geki...@gmail.com

    It's almost perfect, i have only one small suggestion: Remove the "<?php" + "?>" lines of the export if you choose "copy to clipboard".

    The most time someone copies php code to clipboard he will insert it into an existing php code -> in this case he always has to remove the "<?php" + "?>" lines.

    It's just a suggestion! You have done a fast and nice work!
    Thank's a lot!

     
  • Anonymous

    Anonymous - 2012-03-05

    Originally posted by: a...@anse.de

    Yes, agree. Done in recent commit.

     
  • Anonymous

    Anonymous - 2012-03-06

    Originally posted by: geki...@gmail.com

    looks perfect, well done!