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
;
25 use Symfony\Component\DependencyInjection\Definition
;
27 if (! defined('ROOT_PATH')) {
28 define('ROOT_PATH', __DIR__
. DIRECTORY_SEPARATOR
);
31 require_once ROOT_PATH
. 'libraries/common.inc.php';
33 $container = Container
::getDefaultContainer();
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 /** @var Relation $relation */
51 $relation = $containerBuilder->get('relation');
52 $cfgRelation = $relation->getRelationsParam();
53 $tbl_storage_engine = mb_strtoupper(
54 $dbi->getTable($db, $table)->getStatusInfo('Engine')
56 $upd_query = new Table($table, $db, $dbi);
58 /* Define dependencies for the concerned controller */
59 $dependency_definitions = [
60 'db' => $container->get('db'),
61 'table' => $container->get('table'),
62 'options_array' => $options_array,
63 'cfgRelation' => $cfgRelation,
64 'tbl_storage_engine' => $tbl_storage_engine,
66 'existrel_foreign' => [],
67 'upd_query' => $upd_query,
69 if ($cfgRelation['relwork']) {
70 $dependency_definitions['existrel'] = $relation->getForeigners(
77 if (Util
::isForeignKeySupported($tbl_storage_engine)) {
78 $dependency_definitions['existrel_foreign'] = $relation->getForeigners(
86 /** @var Definition $definition */
87 $definition = $containerBuilder->getDefinition(RelationController
::class);
89 static function (string $parameterName, $value) use ($definition) {
90 $definition->replaceArgument($parameterName, $value);
92 array_keys($dependency_definitions),
93 $dependency_definitions
96 /** @var RelationController $controller */
97 $controller = $containerBuilder->get(RelationController
::class);
98 $controller->indexAction();