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\TableRelationController
;
19 use PhpMyAdmin\Di\Container
;
20 use PhpMyAdmin\Relation
;
21 use PhpMyAdmin\Response
;
25 require_once 'libraries/common.inc.php';
27 $container = Container
::getDefaultContainer();
28 $container->factory('PhpMyAdmin\Controllers\Table\TableRelationController');
30 'TableRelationController',
31 'PhpMyAdmin\Controllers\Table\TableRelationController'
33 $container->set('PhpMyAdmin\Response', Response
::getInstance());
34 $container->alias('response', 'PhpMyAdmin\Response');
36 /* Define dependencies for the concerned controller */
37 $db = $container->get('db');
38 $table = $container->get('table');
39 $dbi = $container->get('dbi');
41 'CASCADE' => 'CASCADE',
42 'SET_NULL' => 'SET NULL',
43 'NO_ACTION' => 'NO ACTION',
44 'RESTRICT' => 'RESTRICT',
46 $relation = new Relation($GLOBALS['dbi']);
47 $cfgRelation = $relation->getRelationsParam();
48 $tbl_storage_engine = mb_strtoupper(
49 $dbi->getTable($db, $table)->getStatusInfo('Engine')
51 $upd_query = new Table($table, $db, $dbi);
53 $dependency_definitions = [
54 "options_array" => $options_array,
55 "cfgRelation" => $cfgRelation,
56 "tbl_storage_engine" => $tbl_storage_engine,
57 "upd_query" => $upd_query
59 if ($cfgRelation['relwork']) {
60 $dependency_definitions['existrel'] = $relation->getForeigners(
67 if (Util
::isForeignKeySupported($tbl_storage_engine)) {
68 $dependency_definitions['existrel_foreign'] = $relation->getForeigners(
76 /** @var TableRelationController $controller */
77 $controller = $container->get('TableRelationController', $dependency_definitions);
78 $controller->indexAction();