2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Display table relations for viewing and editing
6 * includes phpMyAdmin relations and InnoDB relations
8 * @todo fix name handling: currently names with dots (.) are not properly handled
9 * for internal relations (but foreign keys relations are correct)
10 * @todo foreign key constraints require both fields being of equal type and size
11 * @todo check foreign fields to be from same type and size, all other makes no sense
12 * @todo if above todos are fullfilled we can add all fields meet requirements
13 * in the select dropdown
16 declare(strict_types
=1);
18 use PhpMyAdmin\Controllers\Table\RelationController
;
19 use PhpMyAdmin\DatabaseInterface
;
20 use PhpMyAdmin\Di\Container
;
21 use PhpMyAdmin\Relation
;
22 use PhpMyAdmin\Response
;
26 if (! defined('ROOT_PATH')) {
27 define('ROOT_PATH', __DIR__
. DIRECTORY_SEPARATOR
);
30 require_once ROOT_PATH
. 'libraries/common.inc.php';
32 $container = Container
::getDefaultContainer();
33 $container->factory(RelationController
::class);
34 $container->set(Response
::class, Response
::getInstance());
35 $container->alias('response', Response
::class);
37 /* Define dependencies for the concerned controller */
38 $db = $container->get('db');
39 $table = $container->get('table');
41 /** @var DatabaseInterface $dbi */
42 $dbi = $container->get(DatabaseInterface
::class);
45 'CASCADE' => 'CASCADE',
46 'SET_NULL' => 'SET NULL',
47 'NO_ACTION' => 'NO ACTION',
48 'RESTRICT' => 'RESTRICT',
50 $relation = new Relation($dbi);
51 $cfgRelation = $relation->getRelationsParam();
52 $tbl_storage_engine = mb_strtoupper(
53 $dbi->getTable($db, $table)->getStatusInfo('Engine')
55 $upd_query = new Table($table, $db, $dbi);
57 $dependency_definitions = [
58 "options_array" => $options_array,
59 "cfgRelation" => $cfgRelation,
60 "tbl_storage_engine" => $tbl_storage_engine,
61 "upd_query" => $upd_query
63 if ($cfgRelation['relwork']) {
64 $dependency_definitions['existrel'] = $relation->getForeigners(
71 if (Util
::isForeignKeySupported($tbl_storage_engine)) {
72 $dependency_definitions['existrel_foreign'] = $relation->getForeigners(
80 /** @var RelationController $controller */
81 $controller = $container->get(RelationController
::class, $dependency_definitions);
82 $controller->indexAction();