<?php
<?php
function getListTableForeignKeysSQL($table, $database = null)
{
$sql = "SELECT DISTINCT k.`CONSTRAINT_NAME`, k.`COLUMN_NAME`, k.`REFERENCED_TABLE_NAME`, ".
"k.`REFERENCED_COLUMN_NAME` /*!50116 , c.update_rule, c.delete_rule */ ".
"FROM information_schema.key_column_usage k /*!50116 ".
"INNER JOIN information_schema.referential_constraints c ON ".
" c.constraint_name = k.constraint_name AND ".
" c.table_name = '$table' */ WHERE k.table_name = '$table'";
$databaseNameSql = null === $database ? "'$database'" : 'DATABASE()';
$sql .= " AND k.table_schema = $databaseNameSql /*!50116 AND c.constraint_schema = $databaseNameSql */";
$sql .= " AND k.`REFERENCED_COLUMN_NAME` is not NULL";
return $sql;
}
echo getListTableForeignKeysSQL('AreaLayoutsUsingPresets'). "\n";
echo getListTableForeignKeysSQL('AreaLayoutsUsingPresets', 'concrete5db'). "\n";
- Output for 5.4.2 - 5.4.45, 5.5.24 - 5.5.29, 5.6.8 - 5.6.13
- Parse error: syntax error, unexpected '<' in /in/HNcms on line 3
Process exited with code 255.
preferences:
179.75 ms | 1395 KiB | 62 Q