User Tools

Site Tools


en:dev:all:devtools:manual-sqlconvert

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. Integrating the structure file (from 2.8.4 only)

Nothing easier than that.
The only thing one needs to do is to copy the install-struct.sql into the root directory of the addon (where also install.php can be found). The code below shows the integration of the files install.php, uninstall.php, and upgrade.php into an addon.

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 *********************************** */

I'd like to write more, but THAT was already all. There is nothing more to do.

PS: the above code sample can also be downloaded by simply clicking on the label….
Manuela v.d.Decken  08.09.2014


en/dev/all/devtools/manual-sqlconvert.txt · Last modified: 29.01.2016 09:49 by Manuela v.d.Decken