PHPackages                             rstoetter/ctabledependencymanager-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. rstoetter/ctabledependencymanager-php

ActiveLibrary[Database &amp; ORM](/categories/database)

rstoetter/ctabledependencymanager-php
=====================================

the repository rstoetter\\ctabledependencymanager-php helps you to keep track of the various table dependencies in a mysql database. It is able to find dependencies, which last over several tables between and to find dependencies with self-referring tables

v1.0.3(8y ago)013MITPHPPHP &gt;=7.0

Since Mar 26Pushed 8y agoCompare

[ Source](https://github.com/rstoetter/ctabledependencymanager-php)[ Packagist](https://packagist.org/packages/rstoetter/ctabledependencymanager-php)[ RSS](/packages/rstoetter-ctabledependencymanager-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

The repository \\rstoetter\\ctabledependencymanager-php
=======================================================

[](#the-repository-rstoetterctabledependencymanager-php)

description
-----------

[](#description)

The class cTableDependencyManager is the main class of the repository \\rstoetter\\ctabledependencymanager-php.

The class cTableDependencyManager keeps the various dependencies to a certain target table. There can be lots of dependency paths to a certain table in the database. The dependency paths can consist of many tables, which establish the dependency between the source table and the target table. Self-referencing tables are considered, too.

Actually merely dependencies of a mysql database are supported

The class \\rstoetter\\ctabledependencymanager\\cTableDependencyManager keeps all dependencies of the database, which refer to a certain target table

dependency paths
----------------

[](#dependency-paths)

Such a dependency path could be the following one:

TST\_AUF\_ITP\_Stichwort\_CLIENT\_CLIENT -&gt; TST\_AUF\_ITP\_Stichwort\_CLIENT -&gt; TST\_AUF\_ITP\_Stichwort -&gt; TST\_AUF\_ITP\_Stichwort -&gt; ITP\_Stichwort -&gt; ITP\_Zeitraum -&gt; Klient -&gt; Auswahl -&gt; AuswahlTyp -&gt; BUCHUNGSKREIS -&gt; MANDANT

- Here the source table TST\_AUF\_ITP\_Stichwort\_CLIENT\_CLIENT depends on the table MANDANT ( the target table, the last one)
- all the tables mentioned before MANDANT refer to MANDANT in a certain way, too - in the given dependency order from right to left
- the dependency path shows, how the tables are connected in the database with FOREIGN KEYs
- The table TST\_AUF\_ITP\_Stichwort is a self referencing table, therefore it is mentioned twice in the dependency path

How can I use it?
-----------------

[](#how-can-i-use-it)

For example, if we want to do a cascading delete in the database and want to delete a record from the table MANDANT, then we have to delete the dependencies in the database, which refer to the table MANDANT in any way.

First we have to delete affected records from TST\_AUF\_ITP\_Stichwort\_CLIENT\_CLIENT, then from TST\_AUF\_ITP\_Stichwort\_CLIENT, then from TST\_AUF\_ITP\_Stichwort and so on, until we can delete the record in MANDANT without offending a constraint in the database.

The class cTableDependencyManager checks the whole database for the constraints between the tables and solves the order of the cascading delete.

It is a powerful weapon in order to ease the burden to keep track of all dependencies in your database.

**BUT BE CAREFUL WHEN USING IT AS IT WOULD HELP TO DELETE ALL RECORDS FROM THE DATABASE WHICH DEPEND ON THE RECORD YOU WANT TO DELETE IN THE TARGET TABLE**

helper classes
--------------

[](#helper-classes)

There are some helper classes, which are significantly involved in adding functionality to the class cTableDependencyManager:

- The class **cTableDependency** implements one dependency between two tables
- The class cTableDependency uses the class **cTableDependencyPath**, which implements the dependency between two tables and provides the table dependency path

You will need PHP 7 or later to use this repository

Usage:
------

[](#usage)

```
$schema_name = 'give me the name of my database';
$table_name = 'give me the name of an existing table in the schema';

// open the database
$mysqli = new mysqli(
                 'the database host',
                 'the database account name',
                 'the password of the database account',
                 $schema_name
             );

// retrieve the key column usage of the database
$obj_ac_key_column_usage = new \rstoetter\libsqlphp\cKEY_COLUMN_USAGE( $schema_name, $mysqli );

// build the sorted key column usage tree of the database
$obj_key_column_usage_tree = new \rstoetter\ckeycolumnusagetree\cKeyColumnUsageTree( $obj_ac_key_column_usage );

// create the table dependency manager for the table $table_name
$obj_table_dependency_manager = new \rstoetter\ctabledependencymanager\cTableDependencyManager( $table_name, $obj_key_column_usage_tree );

// print the table dependecies for the table $table_name managed by the table dependency manager
echo "\n in the database $schema_name refer the following tables to $table_name - directly and indirectly";

for ( $i = 0; $i < $obj_table_dependency_manager->GetTableDependencyCount( ); $i++ ) {

    // retrieve object of type \rstoetter\ctabledependencymanager\cTableDependency
    $obj_table_dependency = $obj_table_dependency_manager->GetTableDependency( $i );
    echo "\n ";
    // GetPathObject( ) returns type \rstoetter\ctabledependencymanager\cTableDependencyPath
    echo $obj_table_dependency->GetPathObject( )->AsString( );

}
```

Installation
------------

[](#installation)

This project assumes you have composer installed. Simply add:

"require" : {

```
"rstoetter/ctabledependencymanager-php" : ">=1.0.0"

```

}

to your composer.json, and then you can simply install with:

composer install

Namespace
---------

[](#namespace)

Use the namespace \\rstoetter\\ctabledependencymanager in order to access the classes provided by the repository ctabledependencymanager-php

More information
----------------

[](#more-information)

See the [project wiki of ctabledependencymanager-php](https://github.com/rstoetter/ctabledependencymanager-php/wiki) for more technical informations.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

2965d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f638bd6cc066cad10d9187777df8782f4b4ccea4eb2b29ffac141d50744a557c?d=identicon)[rstoetter](/maintainers/rstoetter)

---

Top Contributors

[![rstoetter](https://avatars.githubusercontent.com/u/24063757?v=4)](https://github.com/rstoetter "rstoetter (8 commits)")

---

Tags

phpdependencymysqlsqlmanagertabledependenciestables

### Embed Badge

![Health badge](/badges/rstoetter-ctabledependencymanager-php/health.svg)

```
[![Health](https://phpackages.com/badges/rstoetter-ctabledependencymanager-php/health.svg)](https://phpackages.com/packages/rstoetter-ctabledependencymanager-php)
```

###  Alternatives

[ifsnop/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k5.5M68](/packages/ifsnop-mysqldump-php)[clouddueling/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k22.9k](/packages/clouddueling-mysqldump-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
