Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2012
    Posts
    59
    Plugin Contributions
    0

    Default can I remove zen_ prefix from all tables?

    Hi i have zen cart version 1.3.9g I have been searching for a script or a fast way to remove the zen_ prefix because I am moving my site to a new server and the new db has zen_ as a prefix and my other site has no prefix does anyone know of a script to do this or a fast method besides manually changing them?

    thanks

  2. #2
    Join Date
    Jan 2012
    Posts
    59
    Plugin Contributions
    0

    Default Re: removing zen_ prefix from all tables

    nvm find a great script... here you go everyone works perfrect just add your info in it

    PHP Code:
    <?php  
    $db_server 
    "localhost";    // hostname MySQL server  
    $db_username "username";   // username MySQL server  
    $db_password "password";   // password MySQL server  
    $db_name "database";       // database name  
      
    $pattern "pattern_";          // search string  
    $new_pattern "new_pattern_";  // replacement string,   
                                    // can be empty  
      
    // login to MySQL server  
    $link mysql_connect$db_server$db_username$db_password);  
      
    if (!
    $link)  
    {  
      die(
    'Could not connect: ' mysql_error());  
    }  
      
    // list all tables in the database containing the search pattern  
    $sql "SHOW TABLES FROM `" $db_name "`";  
    $sql .= " LIKE '%" $pattern "%'";  
      
    $result mysql_query $sql$link );  
    if (!
    $result)  
    {  
      die(
    "Invalid query: " mysql_error$link ));  
    }  
      
    $renamed 0;  
    $failed 0;  
      
    while ( 
    $row mysql_fetch_array ($result) )  
    {  
      
    // rename every table by replacing the search pattern   
      // with a new pattern  
      
    $table_name $row[0];  
      
    $new_table_name str_replace $pattern$new_pattern$table_name);  
      
      
    $sql "RENAME TABLE `" $db_name "`.`" $table_name "`";  
      
    $sql .= " TO `" $db_name "`.`" $new_table_name "`";  
      
      
    $result_rename mysql_query $sql$link );  
      if (
    $result_rename)  
      {  
        echo 
    "Table `" $table_name "` renamed to :`";  
        echo 
    $new_table_name "`.\n";  
        
    $renamed++;  
      }  
      else  
      {  
        
    // notify when the renaming failed and show reason why  
        
    echo "Renaming of table `" $table_name "` has failed: ";  
        echo 
    mysql_error$link ) . "\n";  
        
    $failed++;  
      }  
    }  
      
    echo 
    $renamed " tables were renamed, " $failed " failed.\n";  
      
    // close connection to MySQL server  
    mysql_close$link );  
    ?>

  3. #3
    Join Date
    Jan 2005
    Location
    Winter Haven, FL
    Posts
    164
    Plugin Contributions
    0

    Default Re: removing zen_ prefix from all tables

    I too have a database with the zen_ prefix that I need to remove. This script looks like what I need. Excuse a couple of dumb questions.

    [FONT=Courier New]<?php
    $db_server
    = "localhost"; [/FONT][FONT=Courier New]// hostname MySQL server
    $db_username = "username"; [/FONT][FONT=Courier New]// username MySQL server
    $db_password = "password"; [/FONT][FONT=Courier New]// password MySQL server
    $db_name = "database"; [/FONT][FONT=Courier New]// database name

    $pattern = "pattern_"; [/FONT][FONT=Courier New]// search string
    $new_pattern = "new_pattern_"; [/FONT][FONT=Courier New]// replacement string,
    // can be empty [/FONT]

    Is all I need to do is change localhost, username, password and database?
    is "pattern_" supposed to be changed to zen_ and "new_pattern" changed to ""

    Thanks a bunch for your help

  4. #4
    Join Date
    Jan 2012
    Posts
    59
    Plugin Contributions
    0

    Default Re: removing zen_ prefix from all tables

    Yes just replace that db info with your and change the pattern_ to whatever you like to remove. And the new_ pattern with whatver you want to replace it with ex. Pattern_ could be zen_ then new_pattern could be "" and that would remove zen _ from the db

  5. #5
    Join Date
    Jan 2005
    Location
    Winter Haven, FL
    Posts
    164
    Plugin Contributions
    0

    Default Re: removing zen_ prefix from all tables

    after I change these items, do I just go to admin/tools/ and past it into the run sql patches?
    Thanks

  6. #6
    Join Date
    Jan 2012
    Posts
    59
    Plugin Contributions
    0

    Default Re: can I remove zen_ prefix from all tables?

    No this is a Php script so name the file something.php and then place it in the folder of your web server that is the base folder. Then go to your websites.com/something.php and it should run and tell you all of the tables modified. Make sure you give the file executable privileges and then once your done remove it from your server .

  7. #7
    Join Date
    Jan 2006
    Posts
    1,632
    Plugin Contributions
    0

    Default Re: Database prefix change

    I just had success with this code.

    My db prefix was "zen" and I just changed it to "zen_"

  8. #8
    Join Date
    Jan 2006
    Posts
    1,632
    Plugin Contributions
    0

    Default Re: Database prefix change

    One thing: taking out zen also renamed the authorizenet table by taking out its "zen", so the payments area didn't come up in admin. I googled and quickly learned how to rename a table.

 

 

Similar Threads

  1. Adding prefix to database tables
    By RyanKent in forum General Questions
    Replies: 3
    Last Post: 11 Sep 2011, 10:48 PM
  2. Stock by Attributes - use a prefix such as "zen_"
    By imfsub12 in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 9 Oct 2008, 08:07 PM
  3. Problem during upgrade (after renaming tables to remove zen_ prefix)
    By rainthebat in forum Upgrading from 1.3.x to 1.3.9
    Replies: 5
    Last Post: 11 Dec 2007, 05:23 PM
  4. Add a prefix to database tables
    By hyperlite635 in forum Installing on a Linux/Unix Server
    Replies: 1
    Last Post: 13 Oct 2007, 10:32 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •