2017 © Pedro PelĂĄez
 

library 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

image

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

  • Monday, March 26, 2018
  • by rstoetter
  • Repository
  • 0 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

The repository \rstoetter\ctabledependencymanager-php

description

The class cTableDependencyManager is the main class of the repository \rstoetter\ctabledependencymanager-php., (*1)

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., (*2)

Actually merely dependencies of a mysql database are supported, (*3)

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

dependency paths

Such a dependency path could be the following one:, (*5)

TST_AUF_ITP_Stichwort_CLIENT_CLIENT -> TST_AUF_ITP_Stichwort_CLIENT -> TST_AUF_ITP_Stichwort -> TST_AUF_ITP_Stichwort -> ITP_Stichwort -> ITP_Zeitraum -> Klient -> Auswahl -> AuswahlTyp -> BUCHUNGSKREIS -> MANDANT, (*6)

  • 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?

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., (*7)

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., (*8)

The class cTableDependencyManager checks the whole database for the constraints between the tables and solves the order of the cascading delete., (*9)

It is a powerful weapon in order to ease the burden to keep track of all dependencies in your database., (*10)

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, (*11)

helper classes

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

  • The class cTableDependency implements one dependency between two tables, (*13)

  • The class cTableDependency uses the class cTableDependencyPath, which implements the dependency between two tables and provides the table dependency path, (*14)

You will need PHP 7 or later to use this repository, (*15)

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

This project assumes you have composer installed. Simply add:, (*16)

"require" : {, (*17)

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

}, (*18)

to your composer.json, and then you can simply install with:, (*19)

composer install, (*20)

Namespace

Use the namespace \rstoetter\ctabledependencymanager in order to access the classes provided by the repository ctabledependencymanager-php, (*21)

More information

See the project wiki of ctabledependencymanager-php for more technical informations., (*22)

The Versions

26/03 2018

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

 

by Rainer Stötter

sql php table mysql manager dependency dependencies tables

26/03 2018

v1.0.3

1.0.3.0

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

  Sources   Download

MIT

The Requires

 

by Rainer Stötter

sql php table mysql manager dependency dependencies tables

26/03 2018

v1.0.2

1.0.2.0

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

  Sources   Download

MIT

The Requires

 

by Rainer Stötter

sql php table mysql manager dependency dependencies tables

26/03 2018

v1.0.1

1.0.1.0

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

  Sources   Download

MIT

The Requires

 

by Rainer Stötter

sql php table mysql manager dependency dependencies tables

26/03 2018

v1.0.0

1.0.0.0

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

  Sources   Download

MIT

The Requires

 

by Rainer Stötter

sql php table mysql manager dependency dependencies tables