#
    # Zurück zum Artikel: http://www.adoptimize.de/glossar/oxid-update-4.5-auf-4.7.php
    #
    # Sat Feb 15 13:23:28 CET 2014 Mathias E. Koch  
    #
    # use this script on your own risk. Always backup before you start
    # and don't forget to backup!
    # the scirpt is quick and dirty but worked for me perfect. 
    #
    # Impressum
    #


    header('Content-type: text/html; charset=UTF-8');

    $linkNew = mysql_connect (DB_HOST_NEU,DB_USER_NEU, DB_PASS_NEU); // database host name
    if(!$linkNew)
        die('Verbindung zur neuen DB schlug fehl');

    $linkOld = mysql_connect(DB_HOST_ALT, DB_USER_ALT, DB_PASS_ALT);
    if(!$linkOld)
        die('Verbindung zur alten DB schlug fehl');

    $dbNew = mysql_select_db(DATENBANK_NAME_NEU, $linkNew);
    $dbOld = mysql_select_db(DATENBANK_NAME_ALT, $linkOld);

    mysql_query('SET NAMES utf8', $linkNew);
    mysql_query('SET NAMES utf8', $linkOld);

    $tables = array(
    'adodb_logsql' ,'ado_ebay_config' ,'ado_export_entities' ,'ado_import_field_values' ,'ado_import_tables' ,'ado_info_fields' , 'ado_info_field_values'
    ,'ado_info_tables' ,'ado_log_entries' ,'ado_order_statuses' ,'ado_platform_orders' ,'ado_upload_feeds' ,'ado_upload_jobs' ,'ag_pending_orders' ,'baskets' ,'bpbankdata' ,'caoautoid'
    ,'idealo_realtime_cron' ,'idealo_realtime_failed_request' ,'idealo_realtime_update' ,'oxacceptedterms' ,'oxaccessoire2article' ,'oxactions' ,'oxactions2article' ,'oxaddress' ,'oxadminlog'
    ,'oxartextends' ,'oxarticles' ,'oxattribute' ,'oxcaptcha' ,'oxcat2cao' ,'oxcategories' ,'oxcategory2attribute' /*,'oxconfig'*/ /*,'oxconfigdisplay'*/ /*,'oxcontents'*/ ,'oxcounters' ,'oxcountry'
    ,'oxdel2delset' ,'oxdelivery' ,'oxdeliveryset' ,'oxdiscount' /*,'oxfiles' ,'oxgbentries'*/ ,'oxgroups' ,'oxidpaypal_transactions' /*,'oxinvitations' ,'oxlinks' ,'oxlogs'*/ ,'oxmanufacturers'
    ,'oxmediaurls' ,'oxnews' ,'oxnewsletter' ,'oxnewssubscribed' ,'oxobject2action' ,'oxobject2article' ,'oxobject2attribute' ,'oxobject2category' ,'oxobject2delivery' ,'oxobject2discount'
    ,'oxobject2group' ,'oxobject2list' ,'oxobject2payment' ,'oxobject2selectlist' ,'oxobject2seodata' ,'oxorder' ,'oxorderarticles' ,'oxorderfiles' /*,'oxpayments'*/ ,'oxprice2article'
    ,'oxpricealarm' ,'oxratings' ,'oxrecommlists' ,'oxremark' ,'oxreviews' ,'oxselectlist' ,'oxseo' ,'oxseohistory' ,'oxseologs' ,'oxshops' ,'oxstates' ,'oxstatistics' ,'oxstatus2cao'
    ,'oxtplblocks' ,'oxuser' ,'oxuserbasketitems' ,'oxuserbaskets' ,'oxuserpayments' ,'oxvendor' ,'oxvendor2cao' ,'oxvouchers' ,'oxvoucherseries');

    foreach($tables AS $tbl) {
        $_next = false;
        if($tbl == 'oxconfig') {
            $next = true;
        }
        if($tbl == 'oxcounters') {
            updateOxcounters();
            $next = true;
        }
        if(!$_next)
            exportTable($tbl);
    }



    function exportTable($tbl) {
        global $dbNew, $dbOld, $linkOld, $linkNew;
        $_qEx = array();
        $_tbl = $tbl;
        $_q = 'SELECT * FROM `'.$_tbl .'` WHERE 1 ';
        $_h = mysql_query($_q, $linkOld);
        if($_h) {
            $_q = 'TRUNCATE `'.$_tbl.'`';
            mysql_query($_q, $linkNew);


            while($_a = mysql_fetch_assoc($_h)) {


                $_q = 'REPLACE INTO `'.$_tbl. '` SET';
                foreach($_a AS $_k => $_v) {
                    switch($_tbl){
                    case('oxadminlog'):
                        if($_k == 'OXDATE')
                            $_k = 'OXTIMESTAMP';
                        break;
                    case('caoautoid'):
                        if($_k == 'CAOID')
                            $_k = 'COI_CAOID';
                        break;
                    case('oxarticles'):
                        if($_k == 'OXCAOID')
                            $_k = 'COI_CAOID';
                        break;
                    case('oxcat2cao'):
                        if($_k == 'OXCAOID')
                            $_k = 'COI_CAOID';
                        if($_k == 'OXCAOTOPID')
                            $_k = 'CAOTOPID';
                        break;
                    case('oxuser'):
                        if($_k == 'OXCAOID')
                            $_k = 'COI_CAOID';
                        break;
                    case('oxorder'):
                        if($_k == 'OXCAOID')
                            $_k = 'COI_CAOID';
                        break;
                    case('oxvendor2cao'):
                        if($_k == 'OXCAOID')
                            $_k = 'COI_CAOID';
                        break;
                    case('oxuserbaskets'):
                        if($_k == 'OXCREATE')
                            $_k = 'OXTIMESTAMP';
                        break;
                    }
                    $_q.= ' `' . $_k . '`="'.mysql_real_escape_string($_v).'",';
                }
                #$_qEx[] = preg_replace('/,$/', ';', $_q);
                $_q = preg_replace('/,$/', ';', $_q);
                mysql_query($_q, $linkNew);
                if(mysql_errno( $linkNew)>0) {
                    echo '
'.mysql_errno( $linkNew); echo '
>'.mysql_error( $linkNew); echo '
>'. $_tbl; die; } } flush(); } } // exportTable function updateOxcounters() { global $dbNew, $dbOld, $linkOld, $linkNew; $_q = 'SELECT * FROM oxcounters WHERE OXIDENT="oxOrder"'; $_h = mysql_query($_q, $linkOld); $_a = mysql_fetch_assoc($_h); if(count($_a)>0) { $_q = 'UPDATE oxcounters SET OXCOUNT="'.$_a['OXCOUNT'].'" WHERE OXIDENT="oxOrder"'; $_h = mysql_query($_q, $linkNew); } } // updateOxcounters