Translated using Weblate (Czech)
[phpmyadmin.git] / tbl_relation.php
blob398818e381d0d0510a975472c0109d817f41e8ee
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
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
14 * @package PhpMyAdmin
16 declare(strict_types=1);
18 use PhpMyAdmin\Controllers\Table\RelationController;
19 use PhpMyAdmin\DatabaseInterface;
20 use PhpMyAdmin\Relation;
21 use PhpMyAdmin\Table;
22 use PhpMyAdmin\Util;
23 use Symfony\Component\DependencyInjection\Definition;
25 if (! defined('ROOT_PATH')) {
26 define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
29 require_once ROOT_PATH . 'libraries/common.inc.php';
31 /* Define dependencies for the concerned controller */
32 $db = $containerBuilder->getParameter('db');
33 $table = $containerBuilder->getParameter('table');
35 /** @var DatabaseInterface $dbi */
36 $dbi = $containerBuilder->get(DatabaseInterface::class);
38 $options_array = [
39 'CASCADE' => 'CASCADE',
40 'SET_NULL' => 'SET NULL',
41 'NO_ACTION' => 'NO ACTION',
42 'RESTRICT' => 'RESTRICT',
44 /** @var Relation $relation */
45 $relation = $containerBuilder->get('relation');
46 $cfgRelation = $relation->getRelationsParam();
47 $tbl_storage_engine = mb_strtoupper(
48 $dbi->getTable($db, $table)->getStatusInfo('Engine') ?? ''
50 $upd_query = new Table($table, $db, $dbi);
52 /* Define dependencies for the concerned controller */
53 $dependency_definitions = [
54 'options_array' => $options_array,
55 'cfgRelation' => $cfgRelation,
56 'tbl_storage_engine' => $tbl_storage_engine,
57 'existrel' => [],
58 'existrel_foreign' => [],
59 'upd_query' => $upd_query,
61 if ($cfgRelation['relwork']) {
62 $dependency_definitions['existrel'] = $relation->getForeigners(
63 $db,
64 $table,
65 '',
66 'internal'
69 if (Util::isForeignKeySupported($tbl_storage_engine)) {
70 $dependency_definitions['existrel_foreign'] = $relation->getForeigners(
71 $db,
72 $table,
73 '',
74 'foreign'
78 /** @var Definition $definition */
79 $definition = $containerBuilder->getDefinition(RelationController::class);
80 array_map(
81 static function (string $parameterName, $value) use ($definition) {
82 $definition->replaceArgument($parameterName, $value);
84 array_keys($dependency_definitions),
85 $dependency_definitions
88 /** @var RelationController $controller */
89 $controller = $containerBuilder->get(RelationController::class);
90 $controller->indexAction();