Index: /branches/version-2_12-dev/test/createEcCubeData-v25.php
===================================================================
--- /branches/version-2_12-dev/test/createEcCubeData-v25.php	(revision 21867)
+++ /branches/version-2_12-dev/test/createEcCubeData-v25.php	(revision 21937)
@@ -143,4 +143,7 @@
         if ($this->delete) {
             $this->objQuery->delete('dtb_category');
+            $existingMaxRank = 0;
+        } else {
+            $existingMaxRank = $this->objQuery->max('rank','dtb_category');
         }
 
@@ -148,4 +151,5 @@
 
         // 全カテゴリ共通の値
+        $sqlval = array();
         $sqlval['creator_id'] = 2;
         $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
@@ -158,5 +162,5 @@
             $sqlval['parent_category_id'] = (string) '0';
             $sqlval['level'] = 1;
-            $sqlval['rank'] = $this->lfGetTotalCategoryrank() - $count;
+            $sqlval['rank'] = $this->lfGetTotalCategoryrank($existingMaxRank) - $count;
             $sqlval['category_id'] = $this->objQuery->nextVal('dtb_category_category_id');
 
@@ -166,11 +170,12 @@
             print(".");
 
+            $top_category_id = $sqlval['category_id'];
             // 中カテゴリを生成
             for ($j = 0; $j < MIDDLE_CATEGORIES_VOLUME; $j++) {
                 $sqlval['category_name'] = sprintf("Category%d%d0", $i,
                                                    $j + MIDDLE_CATEGORIES_VOLUME);
-                $sqlval['parent_category_id'] = (string) $sqlval['category_id'];
+                $sqlval['parent_category_id'] = (string) $top_category_id;
                 $sqlval['level'] = 2;
-                $sqlval['rank'] = $this->lfGetTotalCategoryrank() - $count;
+                $sqlval['rank'] = $this->lfGetTotalCategoryrank($existingMaxRank) - $count;
                 $sqlval['category_id'] = $this->objQuery->nextVal('dtb_category_category_id');
 
@@ -180,4 +185,5 @@
                 print(".");
 
+                $middle_category_id = $sqlval['category_id'];
                 // 小カテゴリを生成
                 for ($k = 0; $k < SMALL_CATEGORIES_VOLUME; $k++) {
@@ -185,7 +191,7 @@
                                                        $i, $j,
                                                        $k + SMALL_CATEGORIES_VOLUME);
-                    $sqlval['parent_category_id'] = (string) $sqlval['category_id'];
+                    $sqlval['parent_category_id'] = (string) $middle_category_id;
                     $sqlval['level'] = 3;
-                    $sqlval['rank'] = $this->lfGetTotalCategoryrank() - $count;
+                    $sqlval['rank'] = $this->lfGetTotalCategoryrank($existingMaxRank) - $count;
                     $sqlval['category_id'] = $this->objQuery->nextVal('dtb_category_category_id');
 
@@ -272,4 +278,5 @@
 
         for ($i = 0; $i < PRODUCTS_VOLUME; $i++) {
+            $sqlval = array();
             $sqlval['product_id'] = $this->objQuery->nextval('dtb_products_product_id');
             $sqlval['name'] = sprintf("商品%d", $i);
@@ -302,4 +309,6 @@
      */
     function createClass($class_name) {
+        $sqlval = array();
+        $arrRaw = array();
         // class_idを取得
         $sqlval['class_id'] = $this->objQuery->nextVal('dtb_class_class_id');
@@ -328,4 +337,6 @@
      */
     function createClassCategory($classcategory_name, $class_id, $class_name) {
+        $sqlval = array();
+        $arrRaw = array();
         $sqlval['classcategory_id'] = $this->objQuery->nextVal('dtb_classcategory_classcategory_id');
         $sqlval['name'] = $classcategory_name;
@@ -368,4 +379,5 @@
         printf("商品ID %d の商品規格を生成しています...\n", $product_id);
 
+        $sqlval = array();
         $sqlval['product_id'] = $product_id;
         $sqlval['product_type_id'] = 1;
@@ -656,7 +668,7 @@
     * 総カテゴリ数を計算し、dtb_categoryに代入するrankに使う
     */
-    function lfGetTotalCategoryrank(){
-        $TotalCategoryrank = (TOP_CATEGORIES_VOLUME * MIDDLE_CATEGORIES_VOLUME * SMALL_CATEGORIES_VOLUME) + (MIDDLE_CATEGORIES_VOLUME * TOP_CATEGORIES_VOLUME) + TOP_CATEGORIES_VOLUME;
-    return $TotalCategoryrank;
+    function lfGetTotalCategoryrank($existingMaxRank = 0){
+        $TotalCategoryrank = (TOP_CATEGORIES_VOLUME * MIDDLE_CATEGORIES_VOLUME * SMALL_CATEGORIES_VOLUME) + (MIDDLE_CATEGORIES_VOLUME * TOP_CATEGORIES_VOLUME) + TOP_CATEGORIES_VOLUME + $existingMaxRank;
+        return $TotalCategoryrank;
     }
 
