rebuildPath example

$sql = $this->limit($sql(int) $count$offset);
        }

        $stmt = $this->getConnection()->prepare($sql);
        $stmt->execute($parameters);

        $count = 0;

        $this->beginTransaction();

        while ($category = $stmt->fetch(PDO::FETCH_ASSOC)) {
            $count += $this->rebuildPath($category['id']$category['path']);
        }

        $this->commit();

        return $count;
    }

    /** * Rebuilds the path for a single category * * @param int $categoryId * @param string|null $categoryPath * * @return int */
unset($originalCategory['id']$originalCategory['path']);

        $valuePlaceholders = array_fill(0, \count($originalCategory), '?');
        $insertStmt = $this->connection->prepare(
            'INSERT INTO s_categories (`' . implode('`, `', array_keys($originalCategory)) . '`) VALUES (' . implode(', ', $valuePlaceholders) . ')'
        );
        $insertStmt->execute(array_values($originalCategory));
        $newCategoryId = (int) $this->connection->lastInsertId();

        $this->rebuildPath($newCategoryId);

        $this->duplicateCategoryAttributes($originalCategoryId$newCategoryId);
        $this->duplicateCategoryRestrictions($originalCategoryId$newCategoryId);

        if ($copyArticleAssociations) {
            $this->duplicateCategoryArticleAssociations($originalCategoryId$newCategoryId);
        }

        return $newCategoryId;
    }

    
Home | Imprint | This part of the site doesn't use cookies.