method getForeignKeys documentation in bbn\Db\Languages\Sql
Return an array with tables and fields related to the searched foreign key.
Example
X::dump($db->getForeignKeys('id', 'table_users', 'db_example'));
// (Array)
function(string $col, string $table, string $db = NULL)
{
if (!$db) {
$db = $this->getCurrent();
}
$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. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2025
BBN Solutions