User Tools

Site Tools


en:dev:all:devtools:manual-sqlconvert

This is an old revision of the document!


FIXME This page is not fully translated, yet. Please help completing the translation.
(remove this paragraph once the translation is finished)

Usage and application of the SQL dump converter

1. Create a structure file using phpMyAdmin

  1. Start phpMyAdmin and open the required database.
  2. Click on the Menu bar, click Export. A screen similar to the following one appears.
  3. Select all the required tables of your addons.
  4. Choose all other settings appropriately according to the template.
  5. Start the download by clicking on the OK button at the bottom.
  6. Save the received *.sql file on your computer.

2. Converting the *.sql file

Normally at this point you really have to do some hard work. Starting from the dump you have to write a lot of lines of beautiful PHP SQL statements by hand, which are then sent individually to the server.
That's too cumbersome for us, so we do that 'a bit' easier:

  1. First the converter is started by clicking on this link: SQL-Dump-Konverter.
  2. Once the converter is started, Browse to the newly created dump file and select it.
  3. Possibly even customize the prefix of the tables to those used in the source database.
  4. If no other special requests are made: click Start Conversion.
  5. after a few moments, the converted file is already available for download.
  6. The store newly created file on your computer, and that's it.

(To reassure about privacy Concerned: Neither the source nor the target file are stored on the server.)

3. Einbinden der Strukturdatei (up to 2.8.4 only)

Nichts einfacher als das.
Dazu muss einfach nur die install-struct.sql in das Hauptverzeichnis des Addons (dort wo auch die install.php zu finden ist) kopiert werden. Der nachfolgende Code zeigt die Einbindung in die Dateien install.php, uninstall.php und upgrade.php eines Addons.

install-upgrade.php
<?php
// Must include code to stop this file being accessed directly
/* -------------------------------------------------------- */
    if (!defined('SYSTEM_RUN')) { die('Cannot access this file directly'); }
/* -------------------------------------------------------- */
// --- process import file to create addons tables ----------
    $sSqlStructFile = __DIR__.'/install-struct.sql';
    if (is_readable($sSqlStructFile)) {
        $oImporter = new SqlImport(WbDatabase::getInstance(), $sSqlStructFile);
        if ($oImporter->doImport(__FILE__)) {
// --- finish process import file ---------------------------------
// --- begin all other individual stuff ---------------------------
 
    /*
     * do all other stuff
     */
 
// --- end of all other individual stuff --------------------------
        } else {
            $aError[] = $oImporter->getError();    
        } //endif
        unset($oImporter);
    } else {
        $aError[] = 'missing or not readable file \"'.basename(__DIR__).'/install-struct.sql\"';
    } //endif
/* **** END INSTALL / UNINSTALL / UPGRADE *********************************** */
uninstall.php
<?php
// Must include code to stop this file being accessed directly
/* -------------------------------------------------------- */
    if (!defined('SYSTEM_RUN')) { die('Cannot access this file directly'); }
/* -------------------------------------------------------- */
// --- begin all other individual stuff ---------------------------
 
    /*
     * do all other stuff
     */
 
// --- end of all other individual stuff --------------------------
// --- process import file to delete addons tables ----------
    $sSqlStructFile = __DIR__.'/install-struct.sql';
    if (is_readable($sSqlStructFile)) {
        $oImporter = new SqlImport(WbDatabase::getInstance(), $sSqlStructFile);
        if (!$oImporter->doImport(__FILE__)) {
            $aError[] = $oImporter->getError();
        }
        unset($oImporter);
    } else {
        $aError[] = 'missing or not readable file \"'.basename(__DIR__).'/install-struct.sql\"';
    } //endif
// --- finish process import file ---------------------------------
/* **** END INSTALL / UNINSTALL / UPGRADE *********************************** */

Ich würde dazu gerne noch mehr schreiben, aber DAS war es bereits. Mehr gibt es nicht zu tun.

PS: das obige Codebeispiel kann durch simples anklicken des Labels auch heruntergeladen werden….
Manuela v.d.Decken  08.09.2014


en/dev/all/devtools/manual-sqlconvert.1438198738.txt.gz · Last modified: 29.07.2015 19:38 by mrbaseman