Post by OSWorX » Tue Dec 07, 2010 4:16 am

eyeweb wrote:Just thought I would update this.

ALthough your script does the job, (well with some slight modifications, such as closing the php off ;) ), ...
1. There is absolulety no need for a closing php.tag if the script is pure php
2. Much worther is the wrong opening php.tag <? which should be always <?php

Forum Rules [en]: viewtopic.php?f=176&t=200480
Forumregeln [de]: viewtopic.php?f=37&t=114208
Commercial Request: viewforum.php?f=88

Image Image Image


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by SXGuy » Tue Dec 07, 2010 11:29 pm

yes, as far as im aware truncate resets all values to 0

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by SapporoGuy » Tue Dec 07, 2010 11:42 pm

Thanks SX for the answer!

930sc ... because it is fun!


User avatar
Active Member

Posts

Joined
Mon Nov 01, 2010 7:29 pm

Post by Stuff4Toys » Fri Dec 24, 2010 5:35 am

php script did Not clear the table for "Latest Products" or the "Categories"

OpenCart Install: www.ChargerPros.com
Shameless Plug: www.Stuff4Toys.com


User avatar
New member

Posts

Joined
Thu Dec 09, 2010 12:18 pm
Location - SW Florida

Post by SXGuy » Fri Dec 24, 2010 6:38 am

just add the table names to the table array that you wish to clear.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by Brook » Thu Dec 30, 2010 12:48 am

I have OpenCart v1.4.9.3 installed. I have an existing database. I am going to create a new database and new OpenCart install using an export of my existing database. I want to reset order, invoice, customer counters etc.

The only things that I want in my new database from my existing database are: (basically anything product related)
products
product descriptions
product catagories
product options
product images
product option images
product related
manufacturers
(I am sure there are more tables that need to be added to this product table list...)

I want to delete everything else in the database and reset all counters orders, invoices, customers, etc.

This is what I was planning on doing.... is this right?
1) Export existing database using PHP Admin
2) Import existing database to new database using PHP Admin
3) Delete all products that I no longer want
4) Delete all product categories that I no longer want
5) Delete all manufacturers that I no longer want
6) Run PHP delete_demo_data.php script (below)

I was planning on running the delete_demo_date.php PHP Script that was posted earlier in this post

Code: Select all

<?
include('config.php');

$db = mysqli_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$tables = array(
    'address',
    'category',
    'category_description',
    'category_to_store',
    'coupon',
    'customer',
    'download',
    'download_description',
    'manufacturer',
    'manufacturer_to_store',
    'product',
    'product_description',
    'product_discount',
    'product_featured',
    'product_image',
    'product_option',
    'product_option_description',
    'product_option_value',
    'product_option_value_description',
    'product_related',
    'product_special',
    'product_to_download',
    'product_to_store',
    'review',
    'store',
    'store_description',
    'product_tags',
    'order',
    'order_download',
    'order_history',
    'order_option',
    'order_product',
    'order_status',
    'order_total',
    'product_to_category',
    'coupon_description',
    'coupon_product',
);

// for each table add a delete line to script
foreach ($tables as $table) {
    $query = "TRUNCATE TABLE `oc_$table`;";
    $result = mysqli_query($db, $query);
    if (!$result) {
        echo "<p>The data from $table was not deleted</p>";
    echo "<p>$query</p>";
    } else {
        echo "<p>The data from $table was deleted</p>";
    }
}

?>
Two questions:
1) Is this a comprehensive list of all OpenCart tables that should be TRUNCATED for OpenCart version 1.4.9.3? If not what tables should I add?
2) I understand that TRUNCATE TABLE opencart_table will reset the counter in the table (is this correct?)

Any help would be appreciated.

Active Member

Posts

Joined
Wed Feb 24, 2010 12:15 am

Post by SapporoGuy » Thu Dec 30, 2010 1:07 am

#2.) as per the reploy above yes.

step 6.) will wipe out all the data in the tables listed in the script. so, possibly your steps above might be useless.

@ this script
opencart should really offer 3 types of data setup:
1.) full demo as of now
2.) data for only the sections that setup up configs and such.
3.) an option to #2 where you