PHP code example of rstoetter / ckeycolumnusagetree-php

1. Go to this page and download the library: Download rstoetter/ckeycolumnusagetree-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rstoetter / ckeycolumnusagetree-php example snippets



   $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 information from the database
   $obj_ac_key_column_usage = new \rstoetter\libsqlphp\cKEY_COLUMN_USAGE( $schema_name, $mysqli );
  
   // build the sorted tree
   $obj_key_column_usage_tree = new \rstoetter\ckeycolumnusagetree\cKeyColumnUsageTree( $obj_ac_key_column_usage );
  
   // search for an item in the tree
   $obj_found = $obj_key_column_usage_tree->SearchByKey( $table_name ); 

   if ( $obj_found !== false ) {
        echo "\n the found node is associated with the table " . $obj_found->GetData( )->m_table_name;
   }