src/bbn/db.php
public function get_foreign_keys(string $col, string $table, string $db = null): array
  {
    if ( !$db ){
      $db = $this->current;
    }
    $res = [];
    $model = $this->modelize();
    foreach ( $model as $tn => $m ){
      foreach ( $m['keys'] as $k => $t ){
        if ( ($t['ref_table'] === $table) &&
          ($t['ref_column'] === $col) &&
          ($t['ref_db'] === $db) &&
          (\count($t['columns']) === 1)
        ){
          if ( !isset($res[$tn]) ){
            $res[$tn] = [$t['columns'][0]];
          }
          else{
            $res[$tn][] = $t['columns'][0];
          }
        }
      }
    }
    return $res;
  }
public function get_foreign_keys(string $col, string $table, string $db = null): array
  {
    if ( !$db ){
      $db = $this->current;
    }
    $res = [];
    $model = $this->modelize();
    foreach ( $model as $tn => $m ){
      foreach ( $m['keys'] as $k => $t ){
        if ( ($t['ref_table'] === $table) &&
          ($t['ref_column'] === $col) &&
          ($t['ref_db'] === $db) &&
          (\count($t['columns']) === 1)
        ){
          if ( !isset($res[$tn]) ){
            $res[$tn] = [$t['columns'][0]];
          }
          else{
            $res[$tn][] = $t['columns'][0];
          }
        }
      }
    }
    return $res;
  }
public function get_foreign_keys ( string $ col , string $ table , string $ db = null ) : array { if ( ! $ db ) { $ db = $ this -> current ; } $ res = [ ] ; $ model = $ this -> modelize ( ) ; foreach ( $ model as $ tn => $ m ) { foreach ( $ m [ 'keys' ] as $ k => $ t ) { if ( ( $ t [ 'ref_table' ] === $ table ) && ( $ t [ 'ref_column' ] === $ col ) && ( $ t [ 'ref_db' ] === $ db ) && ( \ count ( $ t [ 'columns' ] ) === 1 ) ) { if ( ! isset ( $ res [ $ tn ] ) ) { $ res [ $ tn ] = [ $ t [ 'columns' ] [ 0 ] ] ; } else { $ res [ $ tn ] [ ] = $ t [ 'columns' ] [ 0 ] ; } } } } return $ res ; }
Return an array with tables and fields related to the searched foreign key.

```php
bbn\x::dump($db->get_foreign_keys('id', 'table_users', 'db_example'));
// (Array)
```

@param string $col The column's name
@param string $table The table's name
@param string $db The database name if different from the current one
@return array with tables and fields related to the searched foreign key
Return an array with tables and fields related to the searched foreign key .